home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / unix / uucp106d / part04 < prev    next >
Encoding:
Text File  |  1990-06-28  |  61.6 KB  |  2,910 lines

  1. Path: xanth!cs.odu.edu!Amiga-Request
  2. From: Amiga-Request@cs.odu.edu (Amiga Sources/Binaries Moderator)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v90i182: UUCP 1.06D - UNIX compatible uucp/news/mail system, Part04/12
  5. Message-ID: <12973@xanth.cs.odu.edu>
  6. Date: 28 Jun 90 12:22:31 GMT
  7. Sender: news@cs.odu.edu
  8. Reply-To: Matt Dillon <@uunet.uu.net:overload!dillon>
  9. Lines: 2896
  10. Approved: tadguy@cs.odu.edu (Tad Guy)
  11. X-Mail-Submissions-To: Amiga@cs.odu.edu
  12. X-Post-Discussions-To: comp.sys.amiga
  13.  
  14. Submitted-by: Matt Dillon <@uunet.uu.net:overload!dillon>
  15. Posting-number: Volume 90, Issue 182
  16. Archive-name: unix/uucp-1.06d/part04
  17.  
  18. #!/bin/sh
  19. # This is a shell archive.  Remove anything before this line, then unpack
  20. # it by saving it into a file and typing "sh file".  To overwrite existing
  21. # files, type "sh file -c".  You can also feed this as standard input via
  22. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  23. # will see the following message at the end:
  24. #        "End of archive 4 (of 12)."
  25. # Contents:  uucp2/src/GUtil/gnote.c uucp2/src/GUtil/uuserdump.c
  26. #   uucp2/src/anews/followup.c uucp2/src/anews/reply.c
  27. #   uucp2/src/dmail/do_lists.c uucp2/src/dmail/range.c
  28. #   uucp2/src/lib/config.c uucp2/src/lib/list_sort.c
  29. #   uucp2/src/news/postnews.c uucp2/src/unix/tarsplit.c
  30. #   uucp2/src/unix/uudecode.c uucp2/src/uucico/modem.c
  31. #   uucp2/src/uucico/uucp.c uucp2/src/uucico/uux.c
  32. # Wrapped by tadguy@xanth on Thu Jun 28 08:21:21 1990
  33. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  34. if test -f 'uucp2/src/GUtil/gnote.c' -a "${1}" != "-c" ; then 
  35.   echo shar: Will not clobber existing file \"'uucp2/src/GUtil/gnote.c'\"
  36. else
  37. echo shar: Extracting \"'uucp2/src/GUtil/gnote.c'\" \(3473 characters\)
  38. sed "s/^X//" >'uucp2/src/GUtil/gnote.c' <<'END_OF_FILE'
  39. X
  40. X/*
  41. X *  GNOTE.C
  42. X *
  43. X *  $Header: Beta:src/uucp/src/GUtil/RCS/gnote.c,v 1.1 90/02/02 11:58:55 dillon Exp Locker: dillon $
  44. X *
  45. X *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  46. X *
  47. X *  GNOTE hellofile notefile
  48. X *
  49. X *  Allow the user to enter a note and append it to notefile.  See
  50. X *  Getty. Password entry should have a '*' in front of the executable
  51. X *  name for Getty to provide automatic stdin/stdout
  52. X *
  53. X */
  54. X
  55. X#include <stdio.h>
  56. X#include <time.h>
  57. X#include "protos.h"
  58. X#include "version.h"
  59. X
  60. XIDENT(".01");
  61. X
  62. Xchar *GetLine();
  63. Xvoid PutDaChar();
  64. Xvoid FlushChars();
  65. X
  66. Xmain(ac, av)
  67. Xchar *av[];
  68. X{
  69. X    time_t t;
  70. X    char *ptr;
  71. X    FILE *fi;
  72. X
  73. X    time(&t);
  74. X
  75. X    if (ac < 3) {
  76. X    printf("gnote: expect 2 arguments, got %d\n", ac - 1);
  77. X    fflush(stdout);
  78. X    Delay(50*2);
  79. X    exit(1);
  80. X    }
  81. X    printf("%s %s", Ident, ctime(&t));
  82. X    if (fi = fopen(av[1], "r")) {
  83. X    char buf[128];
  84. X    while (fgets(buf, sizeof(buf), fi)) {
  85. X        short len = strlen(buf);
  86. X        if (len > 0 && buf[len-1] == '\n')
  87. X        --len;
  88. X        buf[len++] = 13;
  89. X        buf[len++] = 10;
  90. X        buf[len++] = 0;
  91. X        fputs(buf, stdout);
  92. X    }
  93. X    fclose(fi);
  94. X    }
  95. X    fflush(stdout);
  96. X
  97. X    if ((fi = fopen(av[2], "a")) == NULL) {
  98. X    puts("couldn't open note file");
  99. X    fflush(stdout);
  100. X    Delay(50*2);
  101. X    exit(1);
  102. X    }
  103. X    fprintf(fi, "**NOTE** %s", ctime(&t));
  104. X
  105. X    while (ptr = GetLine()) {
  106. X    if (strcmp(ptr, ".") == 0)
  107. X        break;
  108. X    if (strncmp(ptr, "**NOTE**", 8) == 0)
  109. X        fprintf(fi, " ");
  110. X    fprintf(fi, "%s\n", ptr);
  111. X    }
  112. X    puts("Thank you, hanging up in 8 seconds");
  113. X    fflush(stdout);
  114. X    fclose(fi);
  115. X    Delay(50*8);
  116. X    return(0);
  117. X}
  118. X
  119. X
  120. Xchar *
  121. XGetLine()
  122. X{
  123. X    static char buf[256];
  124. X    static char tab[256];
  125. X    short col = 0;
  126. X    short i = 0;
  127. X    short limit = 5*60;     /*    5 minute idle timeout    */
  128. X    short lcnt = 0;
  129. X    short c;
  130. X
  131. X    for (;;) {
  132. X    c = GetDaChar();
  133. X    if (c == EOF) {
  134. X        clearerr(stdin);
  135. X        ++lcnt;
  136. X        if (lcnt == limit - 30) {
  137. X        puts("\r\n(idle, hangup in 30)\r\n");
  138. X        fflush(stdout);
  139. X        }
  140. X        if (lcnt == limit)
  141. X        break;
  142. X        continue;
  143. X    }
  144. X    lcnt = 0;
  145. X
  146. X    switch(c) {
  147. X    case 10:
  148. X    case 13:
  149. X        PutDaChar('\r');
  150. X        PutDaChar('\n');
  151. X        FlushChars();
  152. X        buf[i] = 0;
  153. X        return(buf);
  154. X    case 8:
  155. X    case 127:
  156. X        if (i) {
  157. X        short n = 1;
  158. X        --i;
  159. X        if (buf[i] == 9)
  160. X            n = tab[i];
  161. X        col -= n;
  162. X        while (n--) {
  163. X            PutDaChar('\010');
  164. X            PutDaChar(' ');
  165. X            PutDaChar('\010');
  166. X        }
  167. X        }
  168. X        break;
  169. X    case 'x'&0x1F:
  170. X        PutDaChar('^');
  171. X        PutDaChar('X');
  172. X        PutDaChar('\r');
  173. X        PutDaChar('\n');
  174. X        i = 0;
  175. X        break;
  176. X    case 'r'&0x1F:
  177. X        PutDaChar('\r');
  178. X        PutDaChar('\n');
  179. X        FlushChars();
  180. X        buf[i] = 0;
  181. X        printf("%s", buf);
  182. X        fflush(stdout);
  183. X        break;
  184. X    case 9:
  185. X        if (i < sizeof(buf) - 2) {
  186. X        tab[i] = 8 - (col & 7);
  187. X        col += tab[i] - 1;  /*    because we ++ below */
  188. X        }
  189. X        /* fall through */
  190. X    default:
  191. X        if (i < sizeof(buf) - 2) {
  192. X        PutDaChar(c);
  193. X        buf[i++] = c;
  194. X        ++col;
  195. X        } else {
  196. X        PutDaChar('g' & 0x1F);
  197. X        }
  198. X        break;
  199. X    }
  200. X    }
  201. X    return(NULL);
  202. X}
  203. X
  204. Xvoid
  205. XFlushChars()
  206. X{
  207. X    PutDaChar(256);
  208. X}
  209. X
  210. Xvoid
  211. XPutDaChar(c)
  212. X{
  213. X    static char buf[256];
  214. X    static short len;
  215. X
  216. X    if (c == 256 || len == sizeof(buf)) {
  217. X    if (len)
  218. X        write(1, buf, len);
  219. X    len = 0;
  220. X    }
  221. X    if (c != 256)
  222. X    buf[len++] = c;
  223. X}
  224. X
  225. X
  226. XGetDaChar()
  227. X{
  228. X    static char buf[256];
  229. X    static short idx, len;
  230. X
  231. X    if (idx == len) {
  232. X    if (read(0, buf, 0) < 0)
  233. X        FlushChars();
  234. X    idx = 0;
  235. X    len = read(0, buf, sizeof(buf));
  236. X    if (len <= 0) {
  237. X        len = 0;
  238. X        return(EOF);
  239. X    }
  240. X    }
  241. X    return((int)buf[idx++]);
  242. X}
  243. X
  244. END_OF_FILE
  245. if test 3473 -ne `wc -c <'uucp2/src/GUtil/gnote.c'`; then
  246.     echo shar: \"'uucp2/src/GUtil/gnote.c'\" unpacked with wrong size!
  247. fi
  248. # end of 'uucp2/src/GUtil/gnote.c'
  249. fi
  250. if test -f 'uucp2/src/GUtil/uuserdump.c' -a "${1}" != "-c" ; then 
  251.   echo shar: Will not clobber existing file \"'uucp2/src/GUtil/uuserdump.c'\"
  252. else
  253. echo shar: Extracting \"'uucp2/src/GUtil/uuserdump.c'\" \(4092 characters\)
  254. sed "s/^X//" >'uucp2/src/GUtil/uuserdump.c' <<'END_OF_FILE'
  255. X
  256. X/*
  257. X *  UUSERDUMP.C
  258. X *
  259. X *  $Header: Beta:src/uucp/src/GUtil/RCS/uuserdump.c,v 1.1 90/02/02 11:58:57 dillon Exp Locker: dillon $
  260. X *
  261. X *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  262. X *
  263. X *  UUSERDUMP filename
  264. X *
  265. X *  KEY THINGS ABOUT UUSER: USED AS STDIN/STDOUT
  266. X *
  267. X *    Currently UUSER: works only with single sessions started
  268. X *    by Getty (this has to do with how UUSER: deals with carrier
  269. X *    detect).  THIS WILL BE FIXED.
  270. X *
  271. X *    (1) Use Level 1 I/O if you can (read/write)
  272. X *        read() returns 0 on timeout, -1 on carrier lost
  273. X *        otherwise, read() returns the immediate number of
  274. X *        data bytes ready up to the amount you requested.
  275. X *        (i.e. if you read(0,buf,256) you can get anywhere from
  276. X *        -1, 0, 1 to 256 back).
  277. X *
  278. X *        write() returns the number you wrote or -1 (lost carrier)
  279. X *
  280. X *        To 'poll' data ready you can read(0, NULL, 0) .. reading
  281. X *        0 bytes returns 0 (data ready) or -1 (data not ready).
  282. X *        NOTE: 0 (data ready) will be returned if carrier is lost
  283. X *        when you read 0 bytes... this is so your program thinks
  284. X *        data is ready and when it does a real read it finds that
  285. X *        carrier was lost!
  286. X *
  287. X *    (2) If you want to use Level 2 I/O (stdio) I suggest you use
  288. X *        it for writing only.  If you really want to use it for
  289. X *        reading remember that the timeout will cause an EOF
  290. X *        condition which must be cleared (clrerr()).  And you
  291. X *        must call ferror() to determine whether an EOF is an
  292. X *        EOF (timeout()) or an actual error (lost carrier).
  293. X */
  294. X
  295. X#include <stdio.h>
  296. X#include "protos.h"
  297. X#include "version.h"
  298. X
  299. XIDENT(".01");
  300. X
  301. Xchar buf[256];
  302. Xshort i;
  303. X
  304. Xint
  305. Xbrk()
  306. X{
  307. X    return(0);
  308. X}
  309. X
  310. Xmain(ac, av)
  311. Xchar *av[];
  312. X{
  313. X    short i;
  314. X    char c;
  315. X    short n;
  316. X    FILE *fi = fopen(av[1], "r");
  317. X
  318. X    onbreak(brk);
  319. X    /*
  320. X     *    set output to line buffering (stdio), else it will use
  321. X     *    file buffering!  Which is bad if we want to catch ^S/^C
  322. X     */
  323. X
  324. X    setvbuf(stdout, NULL, _IOLBF, 0);
  325. X
  326. X
  327. X    if (ac == 1)
  328. X    exit(1);
  329. X
  330. X    if (fi == NULL)
  331. X    printf("Info file %s not available\r\n", av[1]);
  332. X
  333. X    printf("Dumping info file (suggest capture), hit Enter when ready\n");
  334. X    fflush(stdout);
  335. X
  336. X    /*
  337. X     *    Getty uses the R1000 option, so there is a one second timeout
  338. X     *    on reads when no data is present.  If data is present, UUSER:
  339. X     *    returns the number of bytes immediately available regardless of
  340. X     *    how many you requested.
  341. X     */
  342. X
  343. X    for (i = 0; i < 60; ++i) {
  344. X    n = read(0, &c, 1);
  345. X    if (n < 0)              /*  lost carrier */
  346. X        exit(1);
  347. X                /*  success    */
  348. X    if (n > 0 && (c == 10 || c == 13))
  349. X        goto skip;
  350. X    /* timeout */
  351. X    }
  352. X    exit(1);
  353. Xskip:
  354. X    while (fgets(buf, 256, fi)) {
  355. X    short len = strlen(buf);
  356. X    if (CheckControl())
  357. X        break;
  358. X    if (len > 0 && buf[len-1] == '\n')
  359. X        --len;
  360. X    buf[len++] = 13;
  361. X    buf[len++] = 10;
  362. X    buf[len++] = 0;
  363. X    fputs(buf, stdout);
  364. X    }
  365. X    fclose(fi);
  366. X
  367. X    printf("End of dump, any key to disconnect\n");
  368. X    fflush(stdout);
  369. X    for (i = 0; i < 60; ++i) {
  370. X    n = read(0, &c, 1);
  371. X    if (n == 0)     /*  1 second timeout    */
  372. X        continue;
  373. X    break;        /*  any key or lost cd    */
  374. X    }
  375. X    return(0);
  376. X}
  377. X
  378. X/*
  379. X *  Here we use a UUSER: trick ... requesting 0 bytes in a read()
  380. X *  incurs NO timeout.    0 is returned if data is ready, -1 if data
  381. X *  is not ready.
  382. X *
  383. X *  Another way to do it is to dump a seconds worth of data, then
  384. X *  call read() (which blocks for up to 1 second if no data is
  385. X *  ready, but the user doesn't see that because we've already queued
  386. X *  a second's worth of data).  The first method is better because
  387. X *  there is finer granularity (that is, the one used below)
  388. X */
  389. X
  390. XCheckControl()
  391. X{
  392. X    char c = 0;
  393. X    short n;
  394. X
  395. X    if (read(0, NULL, 0) == 0) {    /*  returns 0=data ready, -1=not rdy */
  396. X    read(0, &c, 1);
  397. X    if (c == ('s'&0x1F)) {      /*  ^S           */
  398. X        for (;;) {
  399. X        n = read(0, &c, 1);
  400. X        if (n < 0)          /*  lost carrier */
  401. X            exit(1);
  402. X        if (n == 0)         /*  timeout      */
  403. X            continue;
  404. X        break;            /*    got a key    */
  405. X        }
  406. X        return(0);
  407. X    }
  408. X    if (c == ('c'&0x1F))        /*  ^C           */
  409. X        return(1);
  410. X    }
  411. X    return(0);
  412. X}
  413. X
  414. END_OF_FILE
  415. if test 4092 -ne `wc -c <'uucp2/src/GUtil/uuserdump.c'`; then
  416.     echo shar: \"'uucp2/src/GUtil/uuserdump.c'\" unpacked with wrong size!
  417. fi
  418. # end of 'uucp2/src/GUtil/uuserdump.c'
  419. fi
  420. if test -f 'uucp2/src/anews/followup.c' -a "${1}" != "-c" ; then 
  421.   echo shar: Will not clobber existing file \"'uucp2/src/anews/followup.c'\"
  422. else
  423. echo shar: Extracting \"'uucp2/src/anews/followup.c'\" \(4278 characters\)
  424. sed "s/^X//" >'uucp2/src/anews/followup.c' <<'END_OF_FILE'
  425. X
  426. X/*
  427. X *  FOLLOWUP.C
  428. X */
  429. X
  430. X#include "news.h"
  431. X#include <time.h>
  432. X
  433. Xstatic char Buf[256];
  434. X
  435. Xchar *findheader();
  436. X
  437. Xstatic char *TempFileName = "T:anews.post.tmp";
  438. X
  439. X/*
  440. X *  NOTE: fp can be NULL
  441. X */
  442. X
  443. Xvoid
  444. Xfollowup(cmd, fp, group)
  445. Xint cmd;
  446. XFILE *fp;
  447. Xconst char *group;
  448. X{
  449. X    FILE *fo = fopen(TempFileName, "w");
  450. X    char *ptr;
  451. X    char *nodename = FindConfig(NODENAME);
  452. X    char *system_name = FindConfig(NEWSFEED);
  453. X    char *user       = FindConfig(USERNAME);
  454. X    char *domain   = FindConfig(DOMAINNAME);
  455. X    char *realname = FindConfig(REALNAME);
  456. X    int yes = 0;
  457. X    time_t t = time(NULL);
  458. X    int seq = GetSequence(0);
  459. X    static char *envuser;
  460. X    static char *envrealname;
  461. X
  462. X    if (fo == NULL) {
  463. X    printf("can't create %s\n", TempFileName);
  464. X    return;
  465. X    }
  466. X
  467. X    if (nodename == NULL || system_name == NULL || user == NULL || realname == NULL) {
  468. X    printf("Incomplete Configuration, one of:\n");
  469. X    printf("\t%s %s %s %s\n", NODENAME, NEWSFEED, USERNAME, REALNAME);
  470. X    fclose(fo);
  471. X    return;
  472. X    }
  473. X    if (domain == NULL)
  474. X    domain = ".UUCP";
  475. X
  476. X    /*
  477. X     *    Enviroment variable overides
  478. X     */
  479. X
  480. X    if (envuser == NULL)
  481. X    envuser = MallocEnviro("USER");
  482. X    if (envrealname == NULL)
  483. X    envrealname = MallocEnviro("REALNAME");
  484. X    if (envuser)
  485. X    user = envuser;
  486. X    if (envrealname)
  487. X    realname = envrealname;
  488. X
  489. X    /*
  490. X     *    Create news file
  491. X     */
  492. X
  493. X    fprintf(fo, "Path: %s!%s\n", nodename, user);
  494. X    fprintf(fo, "From: %s@%s%s (%s)\n", user, nodename, domain, realname);
  495. X    fprintf(fo, "Newsgroups: %s\n", group);
  496. X
  497. X    fprintf(fo, "Subject: ");
  498. X    if (fp)
  499. X    fprintf(fo, "Re: ");
  500. X    if (ptr = findheader(fp, "Subject:")) {
  501. X    if (strncmpi(ptr, "re:", 3) == 0)
  502. X        ptr += 3;
  503. X    while (*ptr == ' ' || *ptr == 9)
  504. X        ++ptr;
  505. X    fprintf(fo, "%s", ptr);
  506. X    free(ptr);
  507. X    }
  508. X    fputs("\n", fo);
  509. X
  510. X    fprintf(fo, "Message-Id: <%04d.AA%04d@%s%s>\n", seq, seq, nodename, domain);
  511. X    fprintf(fo, "Date: %s", ctime(&t));
  512. X    fprintf(fo, "Followup-To: %s\n", group);
  513. X    fprintf(fo, "Expires: \n");
  514. X    fprintf(fo, "Keywords: \n");
  515. X
  516. X    fprintf(fo, "Distribution: ");
  517. X    if (ptr = findheader(fp, "Distribution:")) {
  518. X    fprintf(fo, "%s", ptr);
  519. X    free(ptr);
  520. X    } else {
  521. X    fputs("world", fo);
  522. X    }
  523. X    fputs("\n", fo);
  524. X
  525. X    /*
  526. X     *    upper case, include text
  527. X     */
  528. X
  529. X    fputs("\n", fo);
  530. X
  531. X    if (fp && cmd >= 'A' && cmd <= 'Z') {
  532. X    rewind(fp);
  533. X    while (fgets(Buf, sizeof(Buf), fp) && Buf[0] != '\n');
  534. X    while (fgets(Buf, sizeof(Buf), fp)) {
  535. X        fprintf(fo, ">");
  536. X        fputs(Buf, fo);
  537. X    }
  538. X    }
  539. X    fputs("\n", fo);
  540. X
  541. X    /*
  542. X     *    append signature
  543. X     */
  544. X
  545. X    {
  546. X    FILE *fi;
  547. X
  548. X    sprintf(Buf, "%s.signature", user);
  549. X    fi = openlib(Buf);
  550. X    if (fi == NULL)
  551. X        fi = openlib(".signature");
  552. X
  553. X    if (fi) {
  554. X        fputs("--\n", fo);
  555. X        while (fgets(Buf, sizeof(Buf), fi))
  556. X        fputs(Buf, fo);
  557. X        fclose(fi);
  558. X    } else {
  559. X        puts("Warning, no .signature file!");
  560. X    }
  561. X    }
  562. X
  563. X    fclose(fo);
  564. X
  565. X    /*
  566. X     *    Edit the file
  567. X     */
  568. X
  569. X    sprintf(Buf, "%s %s", GetConfig(NEWSEDITOR, GetConfig(EDITOR, "dme")), TempFileName);
  570. X    system(Buf);
  571. X
  572. X    /*
  573. X     *    want to post this?
  574. X     */
  575. X
  576. X    cooked(stdin);
  577. X    printf("Do you want to post this? 'y' or 'n' :");
  578. X    fflush(stdout);
  579. X    while (fgets(Buf, sizeof(Buf), stdin)) {
  580. X    if (strcmp(Buf, "y\n") == 0 || strcmp(Buf, "yes\n") == 0) {
  581. X        yes = 1;
  582. X        break;
  583. X    }
  584. X    if (strcmp(Buf, "n\n") == 0 || strcmp(Buf, "no\n") == 0) {
  585. X        break;
  586. X    }
  587. X    printf("'y' or 'n' please: ");
  588. X    fflush(stdout);
  589. X    }
  590. X    raw(stdin);
  591. X    if (yes) {
  592. X    sprintf(Buf, "%s %s \"%s!rnews\"", GetConfigProgram(UUX), TempFileName, system_name);
  593. X    system(Buf);
  594. X    }
  595. X    remove(TempFileName);
  596. X}
  597. X
  598. X/*
  599. X *  Finds the requested header in the file.  Deletes extra space at the end
  600. X *  and resulting string does not have a newline.
  601. X */
  602. X
  603. Xchar *
  604. Xfindheader(fp, hdr)
  605. XFILE *fp;
  606. Xchar *hdr;
  607. X{
  608. X    int len = strlen(hdr);
  609. X
  610. X    if (fp == NULL)
  611. X    return(NULL);
  612. X
  613. X    rewind(fp);
  614. X
  615. X    while (fgets(Buf, 256, fp) && Buf[0] != '\n') {
  616. X    if (strncmp(Buf, hdr, len) == 0) {
  617. X        char *ptr = Buf;
  618. X        char *ret = malloc(strlen(ptr + len) + 1);
  619. X
  620. X        while (ptr[len] == ' ' || ptr[len] == 9 || ptr[len] == '\n')
  621. X        ++len;
  622. X        strcpy(ret, ptr + len);
  623. X        for (len = strlen(ret) - 1; len >= 0; --len) {
  624. X        if (ret[len] != ' ' && ret[len] != 9 && ret[len] != '\n')
  625. X            break;
  626. X        }
  627. X        ++len;
  628. X        ret[len] = 0;
  629. X        return(ret);
  630. X    }
  631. X    }
  632. X    return(NULL);
  633. X}
  634. X
  635. END_OF_FILE
  636. if test 4278 -ne `wc -c <'uucp2/src/anews/followup.c'`; then
  637.     echo shar: \"'uucp2/src/anews/followup.c'\" unpacked with wrong size!
  638. fi
  639. # end of 'uucp2/src/anews/followup.c'
  640. fi
  641. if test -f 'uucp2/src/anews/reply.c' -a "${1}" != "-c" ; then 
  642.   echo shar: Will not clobber existing file \"'uucp2/src/anews/reply.c'\"
  643. else
  644. echo shar: Extracting \"'uucp2/src/anews/reply.c'\" \(3184 characters\)
  645. sed "s/^X//" >'uucp2/src/anews/reply.c' <<'END_OF_FILE'
  646. X
  647. X/*
  648. X *  REPLY.C
  649. X *
  650. X *  Reply to sender of article (creates, edits a file, then pipes it through
  651. X *  sendmail)
  652. X */
  653. X
  654. X#include "news.h"
  655. X#include <time.h>
  656. X
  657. Xstatic char Buf[256];
  658. X
  659. Xchar *findheader();
  660. Xchar *findheaderNoNull();
  661. X
  662. Xstatic char *TempFileName = "T:anews.post.tmp";
  663. X
  664. X/*
  665. X *  NOTE: fp can be NULL
  666. X */
  667. X
  668. Xvoid
  669. Xreply(cmd, fp, group)
  670. Xint cmd;
  671. XFILE *fp;
  672. Xconst char *group;
  673. X{
  674. X    FILE *fo = fopen(TempFileName, "w");
  675. X    char *ptr;
  676. X    char *user       = FindConfig(USERNAME);
  677. X    char *realname = FindConfig(REALNAME);
  678. X    int yes = 0;
  679. X    time_t t = time(NULL);
  680. X    int seq = GetSequence(0);
  681. X    static char *envuser;
  682. X    static char *envrealname;
  683. X
  684. X    if (fo == NULL) {
  685. X    printf("can't create %s\n", TempFileName);
  686. X    return;
  687. X    }
  688. X
  689. X    if (user == NULL || realname == NULL) {
  690. X    printf("Incomplete Configuration, one of:\n");
  691. X    printf("\t%s %s\n", USERNAME, REALNAME);
  692. X    fclose(fo);
  693. X    remove(TempFileName);
  694. X    return;
  695. X    }
  696. X
  697. X    /*
  698. X     *    Enviroment variable overides
  699. X     */
  700. X
  701. X    if (envuser == NULL)
  702. X    envuser = MallocEnviro("USER");
  703. X    if (envrealname == NULL)
  704. X    envrealname = MallocEnviro("REALNAME");
  705. X    if (envuser)
  706. X    user = envuser;
  707. X    if (envrealname)
  708. X    realname = envrealname;
  709. X
  710. X    /*
  711. X     *    Create email template that can be sent through sendmail, handle
  712. X     *    signature and optional included text.
  713. X     */
  714. X
  715. X    {
  716. X    char *to;
  717. X
  718. X    if ((to = findheader(fp, "Reply-To:")) == NULL)
  719. X        to = findheader(fp, "From:");
  720. X    if (to) {
  721. X        fprintf(fo, "To: %s\n", to);
  722. X        free(to);
  723. X    } else {
  724. X        fprintf(fo, "To: \n");
  725. X    }
  726. X    }
  727. X    fprintf(fo, "Cc: \n");
  728. X    fprintf(fo, "Subject: ");
  729. X
  730. X    if (fp)
  731. X    fprintf(fo, "Re: ");
  732. X    if (ptr = findheader(fp, "Subject:")) {
  733. X    char *xp = ptr;
  734. X    if (strnicmp(xp, "re:", 3) == 0)
  735. X        xp += 3;
  736. X    while (*xp == ' ' || *xp == 9)
  737. X        ++xp;
  738. X    fprintf(fo, "%s", xp);
  739. X    free(ptr);
  740. X    }
  741. X    fputs("\n", fo);
  742. X
  743. X    fputs("\n", fo);
  744. X
  745. X    if (fp && cmd >= 'A' && cmd <= 'Z') {
  746. X    rewind(fp);
  747. X    while (fgets(Buf, sizeof(Buf), fp) && Buf[0] != '\n');
  748. X    while (fgets(Buf, sizeof(Buf), fp)) {
  749. X        fprintf(fo, ">");
  750. X        fputs(Buf, fo);
  751. X    }
  752. X    }
  753. X    fputs("\n", fo);
  754. X
  755. X    /*
  756. X     *    append signature
  757. X     */
  758. X
  759. X    {
  760. X    FILE *fi;
  761. X
  762. X    sprintf(Buf, "%s.signature", user);
  763. X    fi = openlib(Buf);
  764. X    if (fi == NULL)
  765. X        fi = openlib(".signature");
  766. X    if (fi) {
  767. X        fputs("--\n", fo);
  768. X        while (fgets(Buf, sizeof(Buf), fi))
  769. X        fputs(Buf, fo);
  770. X        fclose(fi);
  771. X    } else {
  772. X        puts("Warning, no .signature file!");
  773. X    }
  774. X    }
  775. X
  776. X    fclose(fo);
  777. X
  778. X    /*
  779. X     *    Edit the file
  780. X     */
  781. X
  782. X    sprintf(Buf, "%s %s", GetConfig(NEWSEDITOR, GetConfig(EDITOR, "dme")), TempFileName);
  783. X    system(Buf);
  784. X
  785. X    /*
  786. X     *    want to post this?
  787. X     */
  788. X
  789. X    cooked(stdin);
  790. X    printf("Do you want to send this? 'y' or 'n' :");
  791. X    fflush(stdout);
  792. X    while (fgets(Buf, sizeof(Buf), stdin)) {
  793. X    if (strcmp(Buf, "y\n") == 0 || strcmp(Buf, "yes\n") == 0) {
  794. X        yes = 1;
  795. X        break;
  796. X    }
  797. X    if (strcmp(Buf, "n\n") == 0 || strcmp(Buf, "no\n") == 0) {
  798. X        break;
  799. X    }
  800. X    printf("'y' or 'n' please: ");
  801. X    fflush(stdout);
  802. X    }
  803. X
  804. X    raw(stdin);
  805. X    if (yes) {
  806. X    sprintf(Buf, "%s < %s -f %s", GetConfigProgram(SENDMAIL), TempFileName, user);
  807. X    system(Buf);
  808. X    remove(TempFileName);
  809. X    } else {
  810. X    printf("File left as %s\n", TempFileName);
  811. X    }
  812. X}
  813. X
  814. END_OF_FILE
  815. if test 3184 -ne `wc -c <'uucp2/src/anews/reply.c'`; then
  816.     echo shar: \"'uucp2/src/anews/reply.c'\" unpacked with wrong size!
  817. fi
  818. # end of 'uucp2/src/anews/reply.c'
  819. fi
  820. if test -f 'uucp2/src/dmail/do_lists.c' -a "${1}" != "-c" ; then 
  821.   echo shar: Will not clobber existing file \"'uucp2/src/dmail/do_lists.c'\"
  822. else
  823. echo shar: Extracting \"'uucp2/src/dmail/do_lists.c'\" \(4162 characters\)
  824. sed "s/^X//" >'uucp2/src/dmail/do_lists.c' <<'END_OF_FILE'
  825. X
  826. X/*
  827. X *  DO_LISTS.C
  828. X *
  829. X *  $Header: Beta:src/uucp/src/dmail/RCS/do_lists.c,v 1.1 90/02/02 12:03:33 dillon Exp Locker: dillon $
  830. X *
  831. X *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  832. X *
  833. X *  Global Routines:    DO_SETLIST()
  834. X *            DO_LIST()
  835. X *            DO_SELECT()
  836. X *            DO_DEFER()
  837. X *
  838. X *  Static Routines:    None.
  839. X *
  840. X *    LIST associated commands.
  841. X *
  842. X */
  843. X
  844. X#include <stdio.h>
  845. X#include "dmail.h"
  846. X
  847. X
  848. Xdo_setlist(str)
  849. Xchar *str;
  850. X{
  851. X    int i, fw, idx, localecho = 1;
  852. X    int sac = 1;
  853. X
  854. X    push_break();
  855. X    if (ac > sac && strcmp (av[sac], "-s") == 0) {
  856. X    ++sac;
  857. X    localecho = 0;
  858. X    }
  859. X    hold_load();
  860. X    if (ac > sac) {
  861. X    Listsize = 0;
  862. X    for (i = sac; i < ac; ++i) {
  863. X        fw = atoi(av[i]);
  864. X        if (fw > 4096)
  865. X        fw = 4096;
  866. X        if (fw < 0  ||  (*av[i] < '0'  ||  *av[i] > '9'))
  867. X        fw = 20;
  868. X        else
  869. X        ++i;
  870. X        if (i >= ac)
  871. X        continue;
  872. X        idx = get_extra_ovr (av[i]);
  873. X        if (idx < 0) {
  874. X        printf ("To many entries, cannot load: %s\n", av[i]);
  875. X        fflush (stdout);
  876. X        continue;
  877. X        }
  878. X        header[Listsize] = idx;
  879. X        width[Listsize] = fw;
  880. X        ++Listsize;
  881. X    }
  882. X    }
  883. X    nohold_load();
  884. X    pop_break();
  885. X    if (localecho) {
  886. X    puts ("");
  887. X    printf ("Entry   Width   Field\n\n");
  888. X    for (i = 0; i < Listsize; ++i)
  889. X        printf ("%-6d   %-5d   %s\n", i, width[i], Find[header[i]].search);
  890. X    puts ("");
  891. X    }
  892. X    return (1);
  893. X}
  894. X
  895. X
  896. X/*
  897. X * Pre-position #   0 >     Current article
  898. X *            1 -     Read already
  899. X */
  900. X
  901. Xdo_rlist()
  902. X{
  903. X    int num = 20;
  904. X    int istart = Current, iend = Current;
  905. X    short dir = 1;
  906. X    short try;
  907. X    char buf[64];
  908. X
  909. X    if (av[1])
  910. X    num = atoi(av[1]);
  911. X    if (num < 0) {
  912. X    dir = -1;
  913. X    num = -num;
  914. X    }
  915. X    for (try = 0; try < 2 && num; ++try, (dir = -dir)) {
  916. X    int i;
  917. X    if (dir < 0) {
  918. X        for (i = Current; i >= 0 && num; --i) {
  919. X        if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
  920. X            istart = i;
  921. X            --num;
  922. X        }
  923. X        }
  924. X    } else {
  925. X        for (i = Current; i < Entries && num; ++i) {
  926. X        if (Entry[i].no && !(Entry[i].status & ST_DELETED)) {
  927. X            iend = i;
  928. X            --num;
  929. X        }
  930. X        }
  931. X    }
  932. X    }
  933. X    if (istart != iend) {
  934. X    sprintf(buf, "%d-%d", Entry[istart].no, Entry[iend].no);
  935. X    ac = 2;
  936. X    av[1] = buf;
  937. X    return(do_list());
  938. X    } else {
  939. X    return(-1);
  940. X    }
  941. X}
  942. X
  943. Xdo_list()
  944. X{
  945. X    int i, j;
  946. X    static char curr[10] = { "    " };
  947. X
  948. X    if (ac == 1) {
  949. X    av[1] = "all";
  950. X    ++ac;
  951. X    }
  952. X    if (push_base()) {
  953. X    push_break();
  954. X    pop_base();
  955. X    PAGER (-1);
  956. X    pop_break();
  957. X    return (-1);
  958. X    }
  959. X    PAGER (0);
  960. X    FPAGER ("\n         ");
  961. X    for (j = 0; j < Listsize; ++j) {
  962. X    if (width[j]) {
  963. X        sprintf (Puf, "%-*.*s",
  964. X            2 + width[j],
  965. X            2 + width[j],
  966. X            Find[header[j]].search);
  967. X        FPAGER (Puf);
  968. X    }
  969. X    }
  970. X    FPAGER ("\n");
  971. X    rewind_range (1);
  972. X    while (i = get_range()) {
  973. X    i = indexof(i);
  974. X    if (Entry[i].no  &&  ((Entry[i].status & ST_DELETED) == 0)) {
  975. X        curr[0] = (Entry[i].status & ST_TAG) ? 'T' : ' ';
  976. X        curr[1] = (i == Current) ? '>' : ' ';
  977. X        curr[2] = (Entry[i].status & ST_READ)    ? 'r' : ' ';
  978. X        curr[3] = (Entry[i].status & ST_STORED)  ? 'w' : ' ';
  979. X        sprintf (Puf, "%s%-3d", curr, Entry[i].no);
  980. X        FPAGER (Puf);
  981. X        for (j = 0; j < Listsize; ++j) {
  982. X        if (width[j]) {
  983. X            sprintf(Puf, "  %-*.*s",
  984. X                width[j],
  985. X                width[j],
  986. X                Entry[i].fields[header[j]]);
  987. X            FPAGER (Puf);
  988. X        }
  989. X        }
  990. X        FPAGER ("\n");
  991. X    }
  992. X    }
  993. X    FPAGER ("\n");
  994. X    PAGER (-1);
  995. X    pop_base();
  996. X    return (1);
  997. X}
  998. X
  999. X
  1000. X
  1001. Xdo_select(str, mode)
  1002. Xchar *str;
  1003. X{
  1004. X    int ret = 1;
  1005. X    int localecho = 1;
  1006. X    int avi = 1;
  1007. X    int scr;
  1008. X
  1009. X    if (ac == 1)
  1010. X    return (1);
  1011. X
  1012. X    SelAll = 0;
  1013. X
  1014. X    if (strcmp (av[avi], "-s") == 0) {
  1015. X    localecho = 0;
  1016. X    ++avi;
  1017. X    --ac;
  1018. X    }
  1019. X    switch (ac) {
  1020. X    case 2:
  1021. X    SelAll = 1;
  1022. X    if (localecho)
  1023. X        puts ("SELECT ALL");
  1024. X    ret = m_select (Nulav, mode);
  1025. X    break;
  1026. X    case 1:
  1027. X    break;
  1028. X    default:
  1029. X    ret = m_select (av + avi, mode);
  1030. X    scr = indexof(0);
  1031. X    if (scr > 0  &&  localecho)
  1032. X        printf ("%d  Entries selected\n", Entry[scr].no);
  1033. X    break;
  1034. X    }
  1035. X    if (ret < 0  &&  localecho) {
  1036. X    puts ("Null field");
  1037. X    return (-1);
  1038. X    }
  1039. X    return (1);
  1040. X}
  1041. X
  1042. X
  1043. Xdo_defer()
  1044. X{
  1045. X    register int i, j;
  1046. X
  1047. X    push_break();
  1048. X    j = 1;
  1049. X    for (i = 0; i < Entries; ++i) {
  1050. X    if (Entry[i].no)
  1051. X        Entry[i].no = (Entry[i].status & ST_READ) ? 0 : j++;
  1052. X    }
  1053. X    pop_break();
  1054. X    return (1);
  1055. X}
  1056. X
  1057. END_OF_FILE
  1058. if test 4162 -ne `wc -c <'uucp2/src/dmail/do_lists.c'`; then
  1059.     echo shar: \"'uucp2/src/dmail/do_lists.c'\" unpacked with wrong size!
  1060. fi
  1061. # end of 'uucp2/src/dmail/do_lists.c'
  1062. fi
  1063. if test -f 'uucp2/src/dmail/range.c' -a "${1}" != "-c" ; then 
  1064.   echo shar: Will not clobber existing file \"'uucp2/src/dmail/range.c'\"
  1065. else
  1066. echo shar: Extracting \"'uucp2/src/dmail/range.c'\" \(3191 characters\)
  1067. sed "s/^X//" >'uucp2/src/dmail/range.c' <<'END_OF_FILE'
  1068. X
  1069. X/*
  1070. X * RANGE.C
  1071. X *
  1072. X *  $Header: Beta:src/uucp/src/dmail/RCS/range.c,v 1.1 90/02/02 12:03:54 dillon Exp Locker: dillon $
  1073. X *
  1074. X *  (C) Copyright 1985-1990 by Matthew Dillon,  All Rights Reserved.
  1075. X *
  1076. X *  Global Routines:    REWIND_RANGE()
  1077. X *            GET_RANGE()
  1078. X *            SINGLE_POSITION()
  1079. X *
  1080. X *  Static Routines:    None.
  1081. X *
  1082. X *
  1083. X */
  1084. X
  1085. X#include <stdio.h>
  1086. X#include "dmail.h"
  1087. X
  1088. X
  1089. Xstatic int range_ac;
  1090. Xstatic int in, start, end;
  1091. X
  1092. Xstruct RANOP {
  1093. X    char *name;
  1094. X    int status, kstatus;
  1095. X};
  1096. X
  1097. Xstatic struct RANOP Ranop[] = {
  1098. X    "all",  0,              0,
  1099. X    "tag",  ST_TAG,         ST_DELETED,
  1100. X    "wri",  ST_STORED,      ST_DELETED,
  1101. X    "del",  ST_DELETED,     0,
  1102. X    "mar",  ST_READ,        ST_DELETED,
  1103. X    "unt",  0,              ST_DELETED | ST_TAG,
  1104. X    "unw",  0,              ST_DELETED | ST_STORED,
  1105. X    "und",  0,              ST_DELETED,
  1106. X    "unm",  0,              ST_DELETED | ST_READ,
  1107. X    NULL ,  0,            0 };
  1108. X
  1109. Xvoid
  1110. Xrewind_range(beg)
  1111. X{
  1112. X    Silence = 0;
  1113. X    range_ac = beg;
  1114. X
  1115. X    if (range_ac >= ac) {
  1116. X    start = (Current >= 0) ? Entry[Current].no : 0;
  1117. X    end   = start;
  1118. X    in    = 1;
  1119. X    } else {
  1120. X    in    = 0;
  1121. X    }
  1122. X}
  1123. X
  1124. X
  1125. Xget_range()
  1126. X{
  1127. X    register char *ptr;
  1128. X    register int i;
  1129. X    static int status;        /* Status items required            */
  1130. X    static int kstatus;     /* Status items which cannot be present */
  1131. X
  1132. Xagain:
  1133. X    if (in  &&  start <= end) {
  1134. X    i = indexof(start++);
  1135. X    if (i < 0  || (Entry[i].status & status) != status ||
  1136. X        (Entry[i].status & kstatus))
  1137. X        goto again;
  1138. X    return (start - 1);
  1139. X    }
  1140. X    in = status = kstatus = 0;
  1141. X    if (range_ac >= ac)
  1142. X    return (0);
  1143. X    ptr = av[range_ac++];
  1144. X    if (*ptr == '-') {
  1145. X    if (xstrncmp (ptr, "-s", 2) == 0) {
  1146. X        Silence = 1;
  1147. X        goto again;
  1148. X    }
  1149. X    start = 1;
  1150. X    ++ptr;
  1151. X    goto dash;
  1152. X    }
  1153. X    if (*ptr < '0'  ||  *ptr > '9') {
  1154. X    start = 1;
  1155. X    end = 0;
  1156. X    for (i = 0; Ranop[i].name; ++i) {
  1157. X        if (xstrncmp (ptr, Ranop[i].name, 3) == 0) {
  1158. X        status = Ranop[i].status;
  1159. X        kstatus = Ranop[i].kstatus;
  1160. X        goto imprange;
  1161. X        }
  1162. X    }
  1163. X    goto again;
  1164. X    }
  1165. X    start = atoi(ptr);
  1166. X    while (*(++ptr)) {
  1167. X    if (*ptr == '-') {
  1168. X        ++ptr;
  1169. X        goto dash;
  1170. X    }
  1171. X    }
  1172. X    if (range_ac >= ac)
  1173. X    return (start);
  1174. X    if (*av[range_ac] == '-') {
  1175. X    ptr = av[range_ac++] + 1;
  1176. X    goto dash;
  1177. X    }
  1178. X    return (start);
  1179. Xdash:
  1180. X    if (*ptr) {
  1181. X    end = atoi(ptr);
  1182. X    goto imprange;
  1183. X    }
  1184. X    if (range_ac >= ac) {
  1185. X    end = 0;
  1186. X    goto imprange;
  1187. X    }
  1188. X    end = atoi(av[range_ac++]);
  1189. Ximprange:
  1190. X    if (end == 0) {
  1191. X    end = indexof (0);
  1192. X    if (end < 0)
  1193. X        return (0);
  1194. X    end = Entry[end].no;
  1195. X    }
  1196. X    if (start > end) {
  1197. X    printf ("Bad Range: %s\n", av[range_ac - 1]);
  1198. X    return (0);
  1199. X    }
  1200. X    in = 1;
  1201. X    goto again;
  1202. X}
  1203. X
  1204. X
  1205. Xsingle_position()
  1206. X{
  1207. X    int old = Current;
  1208. X
  1209. X    switch (ac) {
  1210. X    case 1:
  1211. X    break;
  1212. X    case 2:
  1213. X    if (*av[1] == '\0' || (*av[1] == ' ' && strlen(av[1]) == 1))
  1214. X        break;
  1215. X    Current = indexof (atoi(av[1]));
  1216. X    if (Current < 0) {
  1217. X        Current = old;
  1218. X        puts ("Out of Range, 0 will take you to the last entry");
  1219. X        return (-1);
  1220. X    }
  1221. X    break;
  1222. X    default:
  1223. X    puts ("Range not implemented (yet?)");
  1224. X    return (-1);
  1225. X    }
  1226. X    while (Current < Entries  &&  Entry[Current].no == 0)
  1227. X    ++Current;
  1228. X    if (Current >= Entries) {
  1229. X    Current = old;
  1230. X    puts ("No More Messages");
  1231. X    return (-1);
  1232. X    }
  1233. X    position_current();
  1234. X    return (1);
  1235. X}
  1236. X
  1237. X
  1238. END_OF_FILE
  1239. if test 3191 -ne `wc -c <'uucp2/src/dmail/range.c'`; then
  1240.     echo shar: \"'uucp2/src/dmail/range.c'\" unpacked with wrong size!
  1241. fi
  1242. # end of 'uucp2/src/dmail/range.c'
  1243. fi
  1244. if test -f 'uucp2/src/lib/config.c' -a "${1}" != "-c" ; then 
  1245.   echo shar: Will not clobber existing file \"'uucp2/src/lib/config.c'\"
  1246. else
  1247. echo shar: Extracting \"'uucp2/src/lib/config.c'\" \(3478 characters\)
  1248. sed "s/^X//" >'uucp2/src/lib/config.c' <<'END_OF_FILE'
  1249. X
  1250. X/*
  1251. X *  CONFIG.C
  1252. X *
  1253. X *  $Header: Beta:src/uucp/src/lib/RCS/config.c,v 1.1 90/02/02 12:08:37 dillon Exp Locker: dillon $
  1254. X *
  1255. X *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  1256. X *
  1257. X *  Extract fields from UULIB:Config
  1258. X */
  1259. X
  1260. X#include <stdio.h>
  1261. X#include <stdlib.h>
  1262. X#include <fcntl.h>
  1263. X#include "config.h"
  1264. X
  1265. XPrototype char *FindConfig(const char *);
  1266. XPrototype char *GetConfig(const char *, char *);
  1267. XPrototype char *GetConfigDir(char *);
  1268. XPrototype char *GetConfigProgram(char *);
  1269. XPrototype char *MakeConfigPath(const char *, const char *);
  1270. XPrototype char *MallocEnviro(const char *);
  1271. XPrototype FILE *openlib(const char *);
  1272. XPrototype FILE *openlib_write(const char *);
  1273. X
  1274. X#define CTLZ    ('z'&0x1F)
  1275. X
  1276. Xstatic char *ConfBuf = NULL;
  1277. X
  1278. Xchar *
  1279. XFindConfig(field)
  1280. Xconst char *field;
  1281. X{
  1282. X    char *str;
  1283. X    short flen = strlen(field);
  1284. X
  1285. X    if (ConfBuf == NULL) {
  1286. X    FILE *fi;
  1287. X    fi = fopen("S:UUConfig", "r");
  1288. X    if (fi == NULL)
  1289. X        fi = fopen("UULIB:Config", "r");
  1290. X    if (fi) {
  1291. X        long buflen;
  1292. X        fseek(fi, 0L, 2);
  1293. X        buflen = ftell(fi);
  1294. X        fseek(fi, 0L, 0);
  1295. X        if (buflen > 0 && (ConfBuf = malloc(buflen + 1))) {
  1296. X        fread(ConfBuf, buflen, 1, fi);
  1297. X        ConfBuf[buflen] = CTLZ;     /*    can't use \0 */
  1298. X        for (str = ConfBuf; *str; ++str) {
  1299. X            char *bup;
  1300. X            if (*str == '\n') {     /*  make separate strs */
  1301. X            *str = 0;
  1302. X                        /*    remove white space at end */
  1303. X            for (bup = str - 1; bup >= ConfBuf && (*bup == ' ' || *bup == 9); --bup)
  1304. X                *bup = 0;
  1305. X            }
  1306. X        }
  1307. X        } else {
  1308. X        ConfBuf = NULL;
  1309. X        }
  1310. X    } else {
  1311. X        fprintf(stderr, "Couldn't open S:UUConfig or UULIB:Config\n");
  1312. X    }
  1313. X    }
  1314. X    if (ConfBuf == NULL)
  1315. X    return(NULL);
  1316. X    /*
  1317. X     *    Search ConfBuf for Field<space/tab>
  1318. X     */
  1319. X
  1320. X    for (str = ConfBuf; *str != CTLZ; str += strlen(str) + 1) {
  1321. X    if (*str == 0 || *str == '#')
  1322. X        continue;
  1323. X    if (strncmp(str, field, flen) == 0 && (str[flen] == ' ' || str[flen] == '\t')) {
  1324. X        str += flen;
  1325. X        while (*str == ' ' || *str == 9)
  1326. X        ++str;
  1327. X        return(str);
  1328. X    }
  1329. X    }
  1330. X    return(NULL);
  1331. X}
  1332. X
  1333. Xchar *
  1334. XGetConfig(field, def)
  1335. Xconst char *field;
  1336. Xchar *def;
  1337. X{
  1338. X    char *result = FindConfig(field);
  1339. X
  1340. X    if (result == NULL)
  1341. X    result = def;
  1342. X    return(result);
  1343. X}
  1344. X
  1345. Xchar *
  1346. XGetConfigDir(field)
  1347. Xchar *field;
  1348. X{
  1349. X    char *result = FindConfig(field);
  1350. X
  1351. X    if (result == NULL)
  1352. X    result = field + strlen(field) + 1;
  1353. X    return(result);
  1354. X}
  1355. X
  1356. Xchar *
  1357. XGetConfigProgram(field)
  1358. Xchar *field;
  1359. X{
  1360. X    char *result = FindConfig(field);
  1361. X    if (result == NULL)
  1362. X    result = field;
  1363. X    return(result);
  1364. X}
  1365. X
  1366. Xchar *
  1367. XMakeConfigPath(field, trailer)
  1368. Xconst char *field;
  1369. Xconst char *trailer;
  1370. X{
  1371. X    static char Buf[512];
  1372. X    char *result = GetConfigDir(field);
  1373. X    short len = strlen(result) - 1;
  1374. X
  1375. X    if (len > 0 && result[len] == '/' || result[len] == ':')
  1376. X    sprintf(Buf, "%s%s", result, trailer);
  1377. X    else
  1378. X    sprintf(Buf, "%s/%s", result, trailer);
  1379. X    return(Buf);
  1380. X}
  1381. X
  1382. Xchar *
  1383. XMallocEnviro(envname)
  1384. Xconst char *envname;
  1385. X{
  1386. X    int fd;
  1387. X    int len;
  1388. X    char *tmp = malloc(strlen(envname) + 32);
  1389. X
  1390. X    sprintf(tmp, "ENV:%s", envname);
  1391. X    fd = open(tmp, O_RDONLY);
  1392. X    free(tmp);
  1393. X
  1394. X    if (fd < 0)
  1395. X    return(NULL);
  1396. X    len = lseek(fd, 0L, 2);
  1397. X    lseek(fd, 0L, 0);
  1398. X    if (len >= 0) {
  1399. X    tmp = malloc(len + 1);
  1400. X    read(fd, tmp, len);
  1401. X    tmp[len] = 0;
  1402. X    } else {
  1403. X    tmp = NULL;
  1404. X    }
  1405. X    close(fd);
  1406. X    return(tmp);
  1407. X}
  1408. X
  1409. XFILE *
  1410. Xopenlib(filename)
  1411. Xconst char *filename;
  1412. X{
  1413. X    return (fopen(MakeConfigPath(UULIB, filename), "r"));
  1414. X}
  1415. X
  1416. XFILE *
  1417. Xopenlib_write(filename)
  1418. Xconst char *filename;
  1419. X{
  1420. X    return (fopen(MakeConfigPath(UULIB, filename), "w"));
  1421. X}
  1422. X
  1423. END_OF_FILE
  1424. if test 3478 -ne `wc -c <'uucp2/src/lib/config.c'`; then
  1425.     echo shar: \"'uucp2/src/lib/config.c'\" unpacked with wrong size!
  1426. fi
  1427. # end of 'uucp2/src/lib/config.c'
  1428. fi
  1429. if test -f 'uucp2/src/lib/list_sort.c' -a "${1}" != "-c" ; then 
  1430.   echo shar: Will not clobber existing file \"'uucp2/src/lib/list_sort.c'\"
  1431. else
  1432. echo shar: Extracting \"'uucp2/src/lib/list_sort.c'\" \(3949 characters\)
  1433. sed "s/^X//" >'uucp2/src/lib/list_sort.c' <<'END_OF_FILE'
  1434. X
  1435. X/*
  1436. X *  LIST_SORT.C
  1437. X *
  1438. X *    list_sort(list, compare_routine) -> sorted_list
  1439. X *
  1440. X *    Assumes a list of structures, with a pointer to "next" as the first
  1441. X *    field.    It reorders the list into ascending order, and returns the
  1442. X *    new first node's address.  It is order N log(N).
  1443. X *
  1444. X *    The compare routine should return positive if the items are in order,
  1445. X *    and non-positive if they are not.  If the compare routine returns zero
  1446. X *    in case of equality, the sort will be stable.
  1447. X */
  1448. X
  1449. X/*    This routine depends upon compiler-dependant struct layout, but this
  1450. X *    assumption is likely to be fairly commonly valid.
  1451. X */
  1452. X
  1453. X#define _LIST_SORT_C
  1454. X
  1455. X#include <stdio.h>
  1456. X#include "version.h"
  1457. X
  1458. XIDENT(".01");
  1459. X
  1460. Xtypedef struct node_struct {
  1461. X    struct node_struct *next;
  1462. X} node_type;
  1463. X
  1464. Xtypedef int (*cf_type)(node_type *, node_type *);
  1465. X
  1466. XLocal node_type *list_sort(node_type *, cf_type);
  1467. X
  1468. Xnode_type *
  1469. Xlist_sort(node_type *list, cf_type cmp)
  1470. X{
  1471. X    struct node_struct *new[2]; /* back of new stuff */
  1472. X    struct node_struct *old[2]; /* front of old stuff */
  1473. X    int n;            /* current new list */
  1474. X    int o;            /* current old list */
  1475. X    long m, hm;         /* m is merge length, hm is half of that */
  1476. X    long count[2];        /* counts entries drawn from "old" lists */
  1477. X    node_type front[2];     /* artificial front-of-list */
  1478. X
  1479. X    /*
  1480. X     *    The basic notion of this sort is to make sorted sublists longer and
  1481. X     *    longer by merging.  On the Nth pass through the list, sorted
  1482. X     *    sublists of length 2^(N-1) are produced.  Eventually, the entire
  1483. X     *    list is sorted, in log2(N)+1 passes through the list.  There is
  1484. X     *    extra bookkeeping overhead, but minimal extra storage space needed.
  1485. X     *    Counts and clever pointer management substitute for extra "glue"
  1486. X     *    nodes.
  1487. X     *
  1488. X     *    while more than one list
  1489. X     *        while not at end of composite lists
  1490. X     *            for each merge_length(m) block
  1491. X     *                merge lists onto current output list
  1492. X     *            toggle current output list
  1493. X     */
  1494. X
  1495. X    front[0].next = 0;
  1496. X    front[1].next = list;
  1497. X
  1498. X    for (hm = 0, m = 1; front[1].next != 0; hm = m, m <<= 1) {
  1499. X    /* log2(N)+1 times through (since m doubles every time) */
  1500. X
  1501. X    new[0] = &front[0];    old[0] = front[0].next;
  1502. X    new[1] = &front[1];    old[1] = front[1].next;
  1503. X    n = 0;
  1504. X    count[0] = count[1] = 0;
  1505. X
  1506. X    for (;;) {
  1507. X        /*
  1508. X         * N times through (each time through consumes
  1509. X         * one item from one or the other of the old lists)
  1510. X         */
  1511. X
  1512. X        if (old[0] == 0) {
  1513. X        /*
  1514. X         * First composite input list exhausted...
  1515. X         * copy second list onto output, quitting
  1516. X         * if second list is at end.
  1517. X         */
  1518. X
  1519. X        new[n] = new[n]->next = old[1];
  1520. X        if ((old[1] = old[1]->next) == 0)
  1521. X            break;
  1522. X        if (++count[1] >= hm)
  1523. X            n = 1 - n, count[0] = count[1] = 0;
  1524. X        } else if (old[1] == 0) {
  1525. X        /*
  1526. X         * Second composite input list exhausted...
  1527. X         * copy first list onto output, quitting
  1528. X         * if first list is at end.
  1529. X         */
  1530. X
  1531. X        new[n] = new[n]->next = old[0];
  1532. X        if ((old[0] = old[0]->next) == 0)
  1533. X            break;
  1534. X        if (++count[0] >= hm)
  1535. X            n = 1 - n, count[0] = count[1] = 0;
  1536. X        } else if (count[0] >= hm) {
  1537. X        /*
  1538. X         * First logical input list exhausted...
  1539. X         * copy second list onto output, swapping
  1540. X         * output list if second input list ends.
  1541. X         */
  1542. X
  1543. X        new[n] = new[n]->next = old[1];
  1544. X        old[1] = old[1]->next;
  1545. X        if (++count[1] >= hm)
  1546. X            n = 1 - n, count[0] = count[1] = 0;
  1547. X        } else if (count[1] >= hm) {
  1548. X        /*
  1549. X         * Second logical input list exhausted...
  1550. X         * copy first list onto output, swapping
  1551. X         * output list if first input list ends.
  1552. X         */
  1553. X
  1554. X        new[n] = new[n]->next = old[0];
  1555. X        old[0] = old[0]->next;
  1556. X        if (++count[0] >= hm)
  1557. X            n = 1 - n, count[0] = count[1] = 0;
  1558. X        } else {
  1559. X        /*
  1560. X         * Compare the two items at the heads of
  1561. X         * the input lists, and put the smaller
  1562. X         * on the current output list.
  1563. X         */
  1564. X
  1565. X        o = (*cmp)(old[0], old[1]) > 0;
  1566. X        new[n] = new[n]->next = old[o];
  1567. X        old[o] = old[o]->next;
  1568. X        ++count[o];
  1569. X        }
  1570. X    }
  1571. X    new[0]->next = new[1]->next = 0;
  1572. X    }
  1573. X    return front[0].next;
  1574. X}
  1575. X
  1576. END_OF_FILE
  1577. if test 3949 -ne `wc -c <'uucp2/src/lib/list_sort.c'`; then
  1578.     echo shar: \"'uucp2/src/lib/list_sort.c'\" unpacked with wrong size!
  1579. fi
  1580. # end of 'uucp2/src/lib/list_sort.c'
  1581. fi
  1582. if test -f 'uucp2/src/news/postnews.c' -a "${1}" != "-c" ; then 
  1583.   echo shar: Will not clobber existing file \"'uucp2/src/news/postnews.c'\"
  1584. else
  1585. echo shar: Extracting \"'uucp2/src/news/postnews.c'\" \(3427 characters\)
  1586. sed "s/^X//" >'uucp2/src/news/postnews.c' <<'END_OF_FILE'
  1587. X
  1588. X/*
  1589. X *  POSTNEWS.C
  1590. X *
  1591. X *  POSTNEWS <newsfile -f user -r "realname" -R reffile    (BATCH news poster)
  1592. X *                         -x file       (delete file when done)
  1593. X *
  1594. X *  If not specified, obtains user/realname from USERNAME and REALNAME
  1595. X *  enviroment variables.  If either does not exist then gets it from
  1596. X *  the UserName and RealName config entries.
  1597. X *
  1598. X *  If -R is specified the reffile is included in the header list (usually
  1599. X *  contains References: generated by DNews)
  1600. X */
  1601. X
  1602. X#include <stdio.h>
  1603. X#include <stdlib.h>
  1604. X#include <time.h>
  1605. X#include "config.h"
  1606. X#include "version.h"
  1607. X
  1608. XIDENT(".03");
  1609. X
  1610. Xchar TmpBuf[2048];
  1611. Xchar *DelFile[32];
  1612. Xshort Di;
  1613. X
  1614. Xvoid PostNews();
  1615. X
  1616. Xmain(ac, av)
  1617. Xchar *av[];
  1618. X{
  1619. X    short i;
  1620. X    char *from = NULL;
  1621. X    char *real = NULL;
  1622. X    char *reffile = NULL;
  1623. X    FILE *rfi;
  1624. X
  1625. X    for (i = 1; i < ac; ++i) {
  1626. X    char *ptr = av[i];
  1627. X    if (*ptr == '-') {
  1628. X
  1629. X        ptr += 2;
  1630. X
  1631. X        switch(ptr[-1]) {
  1632. X        case 'f':
  1633. X        if (*ptr == 0)
  1634. X            ptr = av[++i];
  1635. X        from = ptr;
  1636. X        break;
  1637. X        case 'r':
  1638. X        if (*ptr == 0)
  1639. X            ptr = av[++i];
  1640. X        real = ptr;
  1641. X        break;
  1642. X        case 'R':
  1643. X        if (*ptr == 0)
  1644. X            ptr = av[++i];
  1645. X        reffile = ptr;
  1646. X        break;
  1647. X        case 'x':
  1648. X        if (*ptr == 0)
  1649. X            ptr = av[++i];
  1650. X        DelFile[Di++] = ptr;
  1651. X        break;
  1652. X        default:
  1653. X        printf("Unknown option: %s\n", ptr - 2);
  1654. X        exit(1);
  1655. X        }
  1656. X    } else {
  1657. X        printf("Illegal argument: %s\n", ptr);
  1658. X        exit(1);
  1659. X    }
  1660. X    }
  1661. X    if (i > ac) {
  1662. X    puts("Expected argument to option");
  1663. X    exit(1);
  1664. X    }
  1665. X    if (from == NULL)
  1666. X    from = GetUserName();
  1667. X    if (real == NULL)
  1668. X    real = GetRealName();
  1669. X
  1670. X    if (reffile)
  1671. X    rfi = fopen(reffile, "r");
  1672. X    else
  1673. X    rfi = NULL;
  1674. X
  1675. X    LockFile("PostNews-UPDATE");
  1676. X    PostNews(stdin, rfi, from, real);
  1677. X    UnLockFile("PostNews-UPDATE");
  1678. X
  1679. X    if (rfi)
  1680. X    fclose(rfi);
  1681. X
  1682. X    while (--Di >= 0)
  1683. X    remove(DelFile[Di]);
  1684. X
  1685. X    return(0);
  1686. X}
  1687. X
  1688. Xvoid
  1689. XPostNews(fi, rfi, user, realname)
  1690. XFILE *fi;
  1691. XFILE *rfi;
  1692. Xchar *user;
  1693. Xchar *realname;
  1694. X{
  1695. X    char *nodename = FindConfig(NODENAME);
  1696. X    char *system_name = FindConfig(NEWSFEED);
  1697. X    char *domain   = FindConfig(DOMAINNAME);
  1698. X    int seq = GetSequence(0);
  1699. X    char tfname[32];
  1700. X    time_t t = time(NULL);
  1701. X    FILE *fo;
  1702. X
  1703. X    sprintf(tfname, "T:post-%d", seq);
  1704. X
  1705. X    if (nodename == NULL || system_name == NULL || user == NULL || realname == NULL) {
  1706. X    puts("Incomplete configuration!  can't post news");
  1707. X    return;
  1708. X    }
  1709. X    if (domain == NULL)
  1710. X    domain = ".UUCP";
  1711. X
  1712. X    fo = fopen(tfname, "w");
  1713. X    if (fo == NULL) {
  1714. X    printf("Unable to create %s\n", tfname);
  1715. X    return;
  1716. X    }
  1717. X
  1718. X    /*
  1719. X     *    Create the actual news file to fo, copying appropriate sections of infile.
  1720. X     */
  1721. X
  1722. X    fprintf(fo, "Path: %s!%s\n", nodename, user);
  1723. X    fprintf(fo, "From: %s@%s%s (%s)\n", user, nodename, domain, realname);
  1724. X    fprintf(fo, "Message-ID: <%s.%04d@%s%s>\n", user, seq, nodename, domain);
  1725. X
  1726. X    /*
  1727. X     *    user headers
  1728. X     */
  1729. X
  1730. X    while (fgets(TmpBuf, sizeof(TmpBuf), fi) && TmpBuf[0] != '\n')
  1731. X    fputs(TmpBuf, fo);
  1732. X
  1733. X    /*
  1734. X     *    system headers (news program -R option to postnews)
  1735. X     *    (usually References:)
  1736. X     */
  1737. X
  1738. X    if (rfi) {
  1739. X    while (fgets(TmpBuf, sizeof(TmpBuf), rfi))
  1740. X        fputs(TmpBuf, fo);
  1741. X    }
  1742. X
  1743. X    /*
  1744. X     *    more headers
  1745. X     */
  1746. X
  1747. X    fprintf(fo, "Date: %s", ctime(&t));
  1748. X
  1749. X    /*
  1750. X     *    remainder of message
  1751. X     */
  1752. X
  1753. X    fprintf(fo, "\n");
  1754. X
  1755. X    while (fgets(TmpBuf, sizeof(TmpBuf), fi))
  1756. X    fputs(TmpBuf, fo);
  1757. X
  1758. X    fclose(fo);
  1759. X
  1760. X    sprintf(TmpBuf, "%s %s \"%s!rnews\"", GetConfigProgram(UUX), tfname, system_name);
  1761. X    system(TmpBuf);
  1762. X    remove(tfname);
  1763. X}
  1764. X
  1765. END_OF_FILE
  1766. if test 3427 -ne `wc -c <'uucp2/src/news/postnews.c'`; then
  1767.     echo shar: \"'uucp2/src/news/postnews.c'\" unpacked with wrong size!
  1768. fi
  1769. # end of 'uucp2/src/news/postnews.c'
  1770. fi
  1771. if test -f 'uucp2/src/unix/tarsplit.c' -a "${1}" != "-c" ; then 
  1772.   echo shar: Will not clobber existing file \"'uucp2/src/unix/tarsplit.c'\"
  1773. else
  1774. echo shar: Extracting \"'uucp2/src/unix/tarsplit.c'\" \(4031 characters\)
  1775. sed "s/^X//" >'uucp2/src/unix/tarsplit.c' <<'END_OF_FILE'
  1776. X
  1777. X/*
  1778. X *  TARSPLIT.C
  1779. X *
  1780. X *  $Header: Beta:src/uucp/src/compress/RCS/tarsplit.c,v 1.1 90/02/02 11:48:06 dillon Exp Locker: dillon $
  1781. X *
  1782. X * TarSplit -- split up tar files (creating directories as needed)
  1783. X *
  1784. X * usage: TarSplit [pathname]
  1785. X *
  1786. X * semantics: splits up tar file taken from stdin (or pathname, if
  1787. X * specified) and creates the files therein under the working data
  1788. X * directory.
  1789. X *
  1790. X * AmigaDOS Version - no support for stdin.
  1791. X */
  1792. X
  1793. X#include <stdio.h>
  1794. X#include "version.h"
  1795. X
  1796. XIDENT(".00");
  1797. X
  1798. X#ifdef    AMIGA
  1799. X#include <stdlib.h>
  1800. X#include <exec/types.h>
  1801. X#ifdef LATTICE
  1802. X#include <proto/all.h>
  1803. X#else
  1804. X#include "protos.h"
  1805. X#endif
  1806. Xtypedef int    bool ;
  1807. Xbool    ChkSumOK() ;
  1808. X#include <libraries/dosextens.h>
  1809. X#else
  1810. X#include <modes.h>
  1811. X#include <bool.h>
  1812. X#define DIRMODE     (S_IREAD | S_IWRITE | S_IEXEC | S_IOREAD | S_IOEXEC)
  1813. X#endif
  1814. X#define TBLOCK    512
  1815. X#define NAMSIZ    100
  1816. X
  1817. Xunion hblock {
  1818. X    char dummy[TBLOCK];
  1819. X    struct header {
  1820. X        char name[NAMSIZ];
  1821. X        char mode[8];
  1822. X        char uid[8];
  1823. X        char gid[8];
  1824. X        char size[12];
  1825. X        char mtime[12];
  1826. X        char chksum[8];
  1827. X        char linkflag;
  1828. X        char linkname[NAMSIZ];
  1829. X    } dbuf;
  1830. X};
  1831. X
  1832. X#define BLKSIZE     (sizeof (union hblock))
  1833. X#define HARDLINK    '1'
  1834. X#define SYMBLINK    '2'
  1835. X#define NORMAL        '\0'
  1836. X
  1837. Xvoid DoFile();
  1838. X
  1839. Xmain(argc, argv)
  1840. Xint    argc;
  1841. Xchar    *argv[];
  1842. X{
  1843. X    FILE        *TarFP;
  1844. X    union hblock    TarBlock;
  1845. X
  1846. X#ifndef AMIGA
  1847. X    /* make the compiler happy about formatted I/O for longs... */
  1848. X    pflinit();
  1849. X#endif
  1850. X
  1851. X    switch(argc) {
  1852. X#ifndef AMIGA
  1853. X    case 1:
  1854. X        TarFP = stdin;
  1855. X        break;
  1856. X#endif
  1857. X    case 2:
  1858. X        if ((TarFP = fopen(argv[1], "r")) == NULL) {
  1859. X            fprintf(stderr, "TarSplit: can't open %s\n", argv[1]);
  1860. X            exit(1);
  1861. X        }
  1862. X        break;
  1863. X    default:
  1864. X        fprintf(stderr, "usage: TarSplit [pathname]\n");
  1865. X        exit(1);
  1866. X    }
  1867. X
  1868. X    for (;;) {
  1869. X        if (fread((char *)&TarBlock, BLKSIZE, 1, TarFP) == NULL) {
  1870. X            fprintf(stderr, "TarSplit: premature EOF\n");
  1871. X            exit(1);
  1872. X        } else if (IsZero(&TarBlock)) {
  1873. X            while (fread((char *)&TarBlock, BLKSIZE, 1, TarFP) != NULL)
  1874. X                ;
  1875. X            break;
  1876. X        } else
  1877. X            DoFile(&TarBlock, TarFP);
  1878. X    }
  1879. X
  1880. X}
  1881. X
  1882. Xbool
  1883. XIsZero(block)
  1884. Xunion hblock    *block;
  1885. X{
  1886. X    int    i;
  1887. X    char    *cblock;
  1888. X
  1889. X    cblock = block->dummy;
  1890. X    for (i = 0; i < TBLOCK; i++)
  1891. X        if (*cblock++ != '\0')
  1892. X            return(FALSE);
  1893. X
  1894. X    return (TRUE);
  1895. X
  1896. X}
  1897. X
  1898. Xvoid
  1899. XDoFile(block, TarFP)
  1900. Xunion hblock    *block;
  1901. XFILE        *TarFP;
  1902. X{
  1903. X    long    FSize;
  1904. X    char    FName[NAMSIZ], *RefName;
  1905. X    int    i;
  1906. X    bool    IsDir, OpenOK;
  1907. X    FILE    *NewFP;
  1908. X
  1909. X    if (!ChkSumOK(block)) {
  1910. X        fprintf(stderr, "TarSplit: bad checksum, name %s?\n",
  1911. X            block->dbuf.name);
  1912. X        exit(1);
  1913. X    }
  1914. X
  1915. X    switch(block->dbuf.linkflag) {
  1916. X    case HARDLINK:
  1917. X    case SYMBLINK:
  1918. X        fprintf(stderr, "TarSplit: can't handle links\n");
  1919. X        exit(1);
  1920. X    case NORMAL:
  1921. X        break;
  1922. X    default:
  1923. X        fprintf(stderr, "TarSplit: unknown linkflag\n");
  1924. X        exit(1);
  1925. X    }
  1926. X
  1927. X#ifdef    AMIGA
  1928. X    if (sscanf(block->dbuf.size, "%12lo", &FSize) != 1) {
  1929. X#else
  1930. X    if (sscanf(block->dbuf.size, "%12O", &FSize) != 1) {
  1931. X#endif
  1932. X        fprintf(stderr, "TarSplit: bad size\n");
  1933. X        exit(1);
  1934. X    }
  1935. X
  1936. X    for (i = 0, RefName = block->dbuf.name; *RefName; i++, RefName++)
  1937. X        FName[i] = *RefName;
  1938. X
  1939. X    if (IsDir = (*(RefName - 1) == '/')) {
  1940. X        FName[i - 1] = '\0';
  1941. X        if (strcmp(FName, ".") == 0)
  1942. X            OpenOK = TRUE;
  1943. X        else
  1944. X#ifdef    AMIGA
  1945. X            {
  1946. X                BPTR Lock;
  1947. X                OpenOK = (Lock = CreateDir(FName)) != 0;
  1948. X                UnLock(Lock) ;
  1949. X            }
  1950. X#else
  1951. X            OpenOK = mknod(FName, DIRMODE) == 0;
  1952. X#endif
  1953. X    } else {
  1954. X        FName[i] = '\0';
  1955. X        OpenOK = (NewFP = fopen(FName, "w")) != NULL;
  1956. X    }
  1957. X
  1958. X    if (!OpenOK) {
  1959. X        fprintf(stderr, "TarSplit: can't create %s\n", FName);
  1960. X        exit(1);
  1961. X    }
  1962. X
  1963. X    for (; FSize > 0; FSize -= TBLOCK) {
  1964. X        if (fread((char *)block, BLKSIZE, 1, TarFP) == NULL) {
  1965. X            fprintf(stderr, "TarSplit: premature EOF\n");
  1966. X            exit(1);
  1967. X        }
  1968. X        if (!IsDir)
  1969. X            fwrite(block->dummy, 1,
  1970. X                (FSize > TBLOCK ? TBLOCK : (int) FSize), NewFP);
  1971. X    }
  1972. X
  1973. X    if (!IsDir)
  1974. X        fclose(NewFP);
  1975. X}
  1976. X
  1977. Xbool
  1978. XChkSumOK(block)
  1979. Xunion hblock    *block;
  1980. X{
  1981. X    long    Accum, ChkSumVal;
  1982. X    int    i;
  1983. X
  1984. X#ifdef    AMIGA
  1985. X    sscanf(block->dbuf.chksum, "%8lo", &ChkSumVal);
  1986. X#else
  1987. X    sscanf(block->dbuf.chksum, "%8O", &ChkSumVal);
  1988. X#endif
  1989. X    for (i = 0; i < 8; i++)
  1990. X        block->dbuf.chksum[i] = ' ';
  1991. X
  1992. X    Accum = 0;
  1993. X    for (i = 0; i < TBLOCK; i++)
  1994. X        Accum += 0xff & block->dummy[i];
  1995. X
  1996. X    return(Accum == ChkSumVal);
  1997. X
  1998. X}
  1999. END_OF_FILE
  2000. if test 4031 -ne `wc -c <'uucp2/src/unix/tarsplit.c'`; then
  2001.     echo shar: \"'uucp2/src/unix/tarsplit.c'\" unpacked with wrong size!
  2002. fi
  2003. # end of 'uucp2/src/unix/tarsplit.c'
  2004. fi
  2005. if test -f 'uucp2/src/unix/uudecode.c' -a "${1}" != "-c" ; then 
  2006.   echo shar: Will not clobber existing file \"'uucp2/src/unix/uudecode.c'\"
  2007. else
  2008. echo shar: Extracting \"'uucp2/src/unix/uudecode.c'\" \(3321 characters\)
  2009. sed "s/^X//" >'uucp2/src/unix/uudecode.c' <<'END_OF_FILE'
  2010. X
  2011. X/*
  2012. X *  UUDECODE.C
  2013. X *
  2014. X *  $Header: Beta:src/uucp/src/compress/RCS/uudecode.c,v 1.1 90/02/02 11:48:08 dillon Exp Locker: dillon $
  2015. X *
  2016. X * uudecode [input]
  2017. X *
  2018. X * create the specified file, decoding as you go.
  2019. X * used with uuencode.
  2020. X */
  2021. X
  2022. X#include <stdio.h>
  2023. X#include "version.h"
  2024. X
  2025. XIDENT(".00");
  2026. X
  2027. X#ifdef UNIX
  2028. X# include <pwd.h>
  2029. X# include <sys/types.h>
  2030. X# include <sys/stat.h>
  2031. X#endif
  2032. X
  2033. X#ifdef VMS
  2034. X# include <types.h>
  2035. X# include <stat.h>
  2036. X#endif
  2037. X
  2038. X/* single character decode */
  2039. X#define DEC(c)  (((c) - ' ') & 077)
  2040. X
  2041. Xvoid outdec();
  2042. Xvoid decode();
  2043. Xvoid xerror();
  2044. X
  2045. Xvoid
  2046. Xmain(argc, argv)
  2047. Xchar **argv;
  2048. X{
  2049. X    FILE *in, *out;
  2050. X#ifdef UNIX | VMS
  2051. X    struct stat sbuf;
  2052. X#endif
  2053. X    int mode;
  2054. X    char dest[128];
  2055. X    char buf[80];
  2056. X
  2057. X    /* optional input arg */
  2058. X    if (argc > 1) {
  2059. X        if ((in = fopen(argv[1], "r")) == NULL) {
  2060. X            xerror(argv[1]);
  2061. X            exit(1);
  2062. X        }
  2063. X        argv++; argc--;
  2064. X    } else
  2065. X        in = stdin;
  2066. X
  2067. X    if (argc != 1) {
  2068. X        printf("Usage: uudecode [infile]\n");
  2069. X        exit(2);
  2070. X    }
  2071. X
  2072. X    /* search for header line */
  2073. X    for (;;) {
  2074. X        if (fgets(buf, sizeof buf, in) == NULL) {
  2075. X            fprintf(stderr, "No begin line\n");
  2076. X            exit(3);
  2077. X        }
  2078. X        if (strncmp(buf, "begin ", 6) == 0)
  2079. X            break;
  2080. X    }
  2081. X    sscanf(buf, "begin %o %s", &mode, dest);
  2082. X
  2083. X#ifdef UNIX
  2084. X    /* handle ~user/file format */
  2085. X    if (dest[0] == '~') {
  2086. X        char *sl;
  2087. X        struct passwd *getpwnam();
  2088. X        char *index();
  2089. X        struct passwd *user;
  2090. X        char dnbuf[100];
  2091. X
  2092. X        sl = index(dest, '/');
  2093. X        if (sl == NULL) {
  2094. X            fprintf(stderr, "Illegal ~user\n");
  2095. X            exit(3);
  2096. X        }
  2097. X        *sl++ = 0;
  2098. X        user = getpwnam(dest+1);
  2099. X        if (user == NULL) {
  2100. X            fprintf(stderr, "No such user as %s\n", dest);
  2101. X            exit(4);
  2102. X        }
  2103. X        strcpy(dnbuf, user->pw_dir);
  2104. X        strcat(dnbuf, "/");
  2105. X        strcat(dnbuf, sl);
  2106. X        strcpy(dest, dnbuf);
  2107. X    }
  2108. X#endif /* UNIX */
  2109. X
  2110. X    /* create output file */
  2111. X    out = fopen(dest, "w");
  2112. X    if (out == NULL) {
  2113. X        xerror(dest);
  2114. X        exit(4);
  2115. X    }
  2116. X#ifdef UNIX | VMS
  2117. X    chmod(dest, mode);
  2118. X#endif
  2119. X
  2120. X    decode(in, out);
  2121. X
  2122. X    if (fgets(buf, sizeof buf, in) == NULL || strcmp(buf, "end\n")) {
  2123. X        fprintf(stderr, "No end line\n");
  2124. X        exit(5);
  2125. X    }
  2126. X    exit(0);
  2127. X}
  2128. X
  2129. X/*
  2130. X * copy from in to out, decoding as you go along.
  2131. X */
  2132. X
  2133. Xvoid
  2134. Xdecode(in, out)
  2135. XFILE *in;
  2136. XFILE *out;
  2137. X{
  2138. X    char buf[80];
  2139. X    char *bp;
  2140. X    int n;
  2141. X
  2142. X    for (;;) {
  2143. X        /* for each input line */
  2144. X        if (fgets(buf, sizeof buf, in) == NULL) {
  2145. X            printf("Short file\n");
  2146. X            exit(10);
  2147. X        }
  2148. X        n = DEC(buf[0]);
  2149. X        if (n <= 0)
  2150. X            break;
  2151. X
  2152. X        bp = &buf[1];
  2153. X        while (n > 0) {
  2154. X            outdec(bp, out, n);
  2155. X            bp += 4;
  2156. X            n -= 3;
  2157. X        }
  2158. X    }
  2159. X}
  2160. X
  2161. X/*
  2162. X * output a group of 3 bytes (4 input characters).
  2163. X * the input chars are pointed to by p, they are to
  2164. X * be output to file f.  n is used to tell us not to
  2165. X * output all of them at the end of the file.
  2166. X */
  2167. X
  2168. Xvoid
  2169. Xoutdec(p, f, n)
  2170. Xchar *p;
  2171. XFILE *f;
  2172. X{
  2173. X    int c1, c2, c3;
  2174. X
  2175. X    c1 = DEC(*p) << 2 | DEC(p[1]) >> 4;
  2176. X    c2 = DEC(p[1]) << 4 | DEC(p[2]) >> 2;
  2177. X    c3 = DEC(p[2]) << 6 | DEC(p[3]);
  2178. X    if (n >= 1)
  2179. X        putc(c1, f);
  2180. X    if (n >= 2)
  2181. X        putc(c2, f);
  2182. X    if (n >= 3)
  2183. X        putc(c3, f);
  2184. X}
  2185. X
  2186. X
  2187. X/* fr: like read but stdio */
  2188. Xint
  2189. Xfr(fd, buf, cnt)
  2190. XFILE *fd;
  2191. Xchar *buf;
  2192. Xint cnt;
  2193. X{
  2194. X    int c, i;
  2195. X
  2196. X    for (i=0; i<cnt; i++) {
  2197. X        c = getc(fd);
  2198. X        if (c == EOF)
  2199. X            return(i);
  2200. X        buf[i] = c;
  2201. X    }
  2202. X    return (cnt);
  2203. X}
  2204. X
  2205. X/*
  2206. X * Return the ptr in sp at which the character c appears;
  2207. X * NULL if not found
  2208. X */
  2209. X
  2210. Xchar *
  2211. Xindex(sp, c)
  2212. Xregister char *sp, c;
  2213. X{
  2214. X    do {
  2215. X        if (*sp == c)
  2216. X            return(sp);
  2217. X    } while (*sp++);
  2218. X    return(NULL);
  2219. X}
  2220. X
  2221. Xvoid
  2222. Xxerror(err)
  2223. Xchar *err;
  2224. X{
  2225. X    printf("Can not open file \"%s\"\n", err);
  2226. X}
  2227. X
  2228. END_OF_FILE
  2229. if test 3321 -ne `wc -c <'uucp2/src/unix/uudecode.c'`; then
  2230.     echo shar: \"'uucp2/src/unix/uudecode.c'\" unpacked with wrong size!
  2231. fi
  2232. # end of 'uucp2/src/unix/uudecode.c'
  2233. fi
  2234. if test -f 'uucp2/src/uucico/modem.c' -a "${1}" != "-c" ; then 
  2235.   echo shar: Will not clobber existing file \"'uucp2/src/uucico/modem.c'\"
  2236. else
  2237. echo shar: Extracting \"'uucp2/src/uucico/modem.c'\" \(3827 characters\)
  2238. sed "s/^X//" >'uucp2/src/uucico/modem.c' <<'END_OF_FILE'
  2239. X
  2240. X/*
  2241. X *  MODEM.C
  2242. X *
  2243. X *  (C) Copyright 1989-1990 by Matthew Dillon,  All Rights Reserved.
  2244. X *
  2245. X *  $Header: Beta:src/uucp/src/uucico/RCS/modem.c,v 1.1 90/02/02 11:56:00 dillon Exp Locker: dillon $
  2246. X */
  2247. X
  2248. X#include "includes.h"
  2249. X#include "uucp.h"
  2250. X#include "log.h"
  2251. X
  2252. XPrototype void openline(void);
  2253. XPrototype int  get_baud(void);
  2254. XPrototype void modem_init(void);
  2255. XPrototype int  dial_nbr(const char *);
  2256. XPrototype void reset_modem(void);
  2257. X
  2258. X/*
  2259. X *  NOTE:   modem stuff pretty much ignored if we are run from
  2260. X *        a getty.
  2261. X */
  2262. X
  2263. X#define MULTIMODEM    /*  I have a multi-modem    */
  2264. X
  2265. Xextern int Getty;
  2266. Xextern int IgnoreCD;
  2267. X
  2268. X
  2269. X
  2270. Xvoid
  2271. Xopenline()
  2272. X{
  2273. X    signal(SIGINT,sigint);
  2274. X    IgnoreCD |= 4;
  2275. Xstart_again:
  2276. X    chkabort();
  2277. X    if (instr("CONNECT", 7))
  2278. X    goto start_again;
  2279. X
  2280. X
  2281. X#ifdef MULTIMODEM
  2282. X
  2283. X#else
  2284. X    set_baud(get_baud());
  2285. X#endif
  2286. X    Delay(120); /* sleep 2 seconds */
  2287. X
  2288. X    IgnoreCD &= ~4;
  2289. X}
  2290. X
  2291. X#ifndef MULTIMODEM
  2292. X
  2293. Xint
  2294. Xget_baud()
  2295. X{
  2296. X/* We've seen the CONNECT message, now we must see what baud rate
  2297. X   we've connected with */
  2298. X/* gather input until \r then see if it's 300, 1200, or 2400 */
  2299. X/* this is for hayes compatibles */
  2300. X
  2301. X    int data;
  2302. X    char rate[10];
  2303. X    int rate_inx = 0;
  2304. X
  2305. X    DEBUG(2,"looking for baud rate\n",0);
  2306. X
  2307. X    while ( ((data = xgetc(BYTE_TO)) != EOF) && ((char)data != '\r')) {
  2308. X        if ((char)data == ' ') continue;
  2309. X        rate[rate_inx++] = (char)data;
  2310. X    }
  2311. X    DEBUG(2, "found baud rate of %s\n", rate);
  2312. X    if (strncmp(rate,"1200",4) == 0) return 1200;
  2313. X    if (strncmp(rate,"2400",4) == 0) return 2400;
  2314. X    if (rate_inx == 0) return 300;
  2315. X    return 1200;  /* default */
  2316. X}
  2317. X
  2318. X#endif
  2319. X
  2320. Xvoid
  2321. Xmodem_init()
  2322. X{
  2323. X    reset_modem();
  2324. X}
  2325. X
  2326. X/*
  2327. X * Simple dialer routine.  Needs replacement with a full blown
  2328. X * script driven dialer.  Next week maybe :-).    FIXME.
  2329. X */
  2330. X
  2331. Xint
  2332. Xdial_nbr(nbr)
  2333. Xconst char *nbr;
  2334. X{
  2335. X    char  *dial;
  2336. X    int   i;
  2337. X
  2338. X    IgnoreCD |= 4;
  2339. X
  2340. X    dial = malloc(strlen(nbr) + 16);
  2341. X
  2342. X    dial[0] = 0;
  2343. X    if (strncmp(nbr, "AT", 2) != 0 && strncmp(nbr, "at", 2) != 0)
  2344. X    strcpy(dial, "ATDT");
  2345. X    strcat(dial, nbr);
  2346. X    strcat(dial, "\r");
  2347. X
  2348. X    DEBUG(2,"dialing %s\n", dial);
  2349. X
  2350. X    twrite(dial, strlen(dial));
  2351. X
  2352. X    i = instr("CONNECT", 7);
  2353. X
  2354. X    if (i == 0)     /*  for those modems which don't bring CD up */
  2355. X    Delay(50);  /*  immediately                              */
  2356. X
  2357. X    IgnoreCD &= ~4;
  2358. X
  2359. X    free(dial);
  2360. X
  2361. X    return (i);
  2362. X}
  2363. X
  2364. X/*
  2365. X *  RESET_MODEM()
  2366. X *
  2367. X *  If run from a Getty we do NOT reset the modem, which would
  2368. X *  disconnect an already connected connection.
  2369. X *
  2370. X *  Note that the delay between CloseSerial() and OpenSerial() only
  2371. X *  serves to give the Getty, if running, time to lock the port and
  2372. X *  begin a disconnect sequence.
  2373. X */
  2374. X
  2375. Xvoid
  2376. Xreset_modem()
  2377. X{
  2378. X    if (Getty)          /*  called from a getty             */
  2379. X    return;
  2380. X    DEBUG(4, "Beg-Reset\n", 0);
  2381. X    CloseSerial();      /*  drop dtr            */
  2382. X    Delay(50*3);        /*  delay 3 seconds     */
  2383. X    DEBUG(4, "End-Reset-1\n", 0);
  2384. X    OpenSerial();       /*  re-open serial      */
  2385. X    DEBUG(4, "End-Reset-2\n", 0);
  2386. X}
  2387. X
  2388. X#ifdef NOTDEF
  2389. X
  2390. X    if (GettyCmd(DeviceName, DeviceUnit, '0', NULL) == 0)
  2391. X    return;
  2392. X
  2393. X    /*
  2394. X     *    Getty doesn't exist, we have to reset the modem ourselves!
  2395. X     */
  2396. X
  2397. X    IgnoreCD |= 4;
  2398. X
  2399. X#ifdef MULTIMODEM
  2400. X    set_baud(19200);
  2401. X
  2402. X    if (CheckCarrier()) {
  2403. X    Delay(60);
  2404. X    twrite("+++", 3);
  2405. X    Delay(120);
  2406. X    }
  2407. X    twrite("ATH0\r", 5);
  2408. X    instr("OK\r\n", 4);
  2409. X    twrite("ATZ\r", 4);
  2410. X    instr("OK\r\n", 4);
  2411. X    twrite("ATZ\r", 4);
  2412. X    instr("OK\r\n", 4);
  2413. X
  2414. X    /*amiga_closeopen();*/
  2415. X    sprintf(init, "%s\r", "ATM0S0=2X4$BA0");
  2416. X    if (debug > 0)
  2417. X    init[3] = '1';
  2418. X    twrite(init, strlen(init));
  2419. X    instr("OK\r\n",4);
  2420. X#else
  2421. X    twrite("+++", 3);
  2422. X    Delay(60);
  2423. X    twrite("ATH0\r", 5);
  2424. X    Delay(120);
  2425. X    twrite("ATZ\r", 4);
  2426. X    Delay(60);
  2427. X    twrite("ATZ\r", 4);
  2428. X    Delay(60);
  2429. X    sprintf(init, "%s\r", "ATS2");
  2430. X    twrite(init, strlen(init));
  2431. X    Delay(60);
  2432. X#endif
  2433. X    IgnoreCD &= ~4;
  2434. X}
  2435. X
  2436. X#endif
  2437. X
  2438. END_OF_FILE
  2439. if test 3827 -ne `wc -c <'uucp2/src/uucico/modem.c'`; then
  2440.     echo shar: \"'uucp2/src/uucico/modem.c'\" unpacked with wrong size!
  2441. fi
  2442. # end of 'uucp2/src/uucico/modem.c'
  2443. fi
  2444. if test -f 'uucp2/src/uucico/uucp.c' -a "${1}" != "-c" ; then 
  2445.   echo shar: Will not clobber existing file \"'uucp2/src/uucico/uucp.c'\"
  2446. else
  2447. echo shar: Extracting \"'uucp2/src/uucico/uucp.c'\" \(4098 characters\)
  2448. sed "s/^X//" >'uucp2/src/uucico/uucp.c' <<'END_OF_FILE'
  2449. X
  2450. X/*
  2451. X *   UUCP.c written by William Loftus
  2452. X *   Copyright 1988 by William Loftus.    All rights reserved.
  2453. X *
  2454. X *  $Header: Beta:src/uucp/src/uucico/RCS/uucp.c,v 1.1 90/02/02 11:56:13 dillon Exp Locker: dillon $
  2455. X *
  2456. X */
  2457. X
  2458. X#include <stdio.h>
  2459. X#include <stdlib.h>
  2460. X#include <string.h>
  2461. X#include "version.h"
  2462. X
  2463. XIDENT(".01");
  2464. X
  2465. Xchar to_buf[128];
  2466. Xchar from_buf[128];
  2467. Xchar path[128];
  2468. Xchar user[8];
  2469. X
  2470. Xchar command_file[128];
  2471. Xint seq;
  2472. X
  2473. Xvoid BuildReceiveFile();
  2474. Xvoid BuildSendFile();
  2475. Xvoid read_ctl();
  2476. Xchar *expand_file();
  2477. Xchar *strchr();
  2478. Xchar *getcwd();
  2479. X
  2480. X#define TRUE 1
  2481. X#define FALSE 0
  2482. X
  2483. XCXBRK()
  2484. X{
  2485. X    return(0);
  2486. X}
  2487. X
  2488. Xvoid
  2489. Xmain(argc,argv)
  2490. Xint argc;
  2491. Xchar **argv;
  2492. X{
  2493. X    int to_bang, from_bang;
  2494. X
  2495. X    if (argc != 3) {
  2496. X    printf("Usage: UUCP from_file to_file\n");
  2497. X    exit(1);
  2498. X    } else {
  2499. X    strcat(from_buf, argv[1]);
  2500. X    strcat(to_buf, argv[2]);
  2501. X    }
  2502. X
  2503. X    getcwd(path,128);
  2504. X
  2505. X    if (chdir(GetConfigDir(UUSPOOL))) {
  2506. X    printf("Couldn't change current working directory to %s\n", GetConfigDir(UUSPOOL));
  2507. X    exit(1);
  2508. X    }
  2509. X
  2510. X    read_ctl();
  2511. X
  2512. X    seq = GetSequence(2);
  2513. X    if (seq < 0) {
  2514. X    chdir(path);
  2515. X    exit(1);
  2516. X    }
  2517. X
  2518. X    from_bang = (int)strchr(from_buf,'!');
  2519. X    to_bang = (int)strchr(to_buf,'!');
  2520. X
  2521. X    if (from_bang && to_bang) {
  2522. X    printf("Can not specify a remote system in both arguments.\n");
  2523. X    chdir(path);
  2524. X    exit(1);
  2525. X    }
  2526. X
  2527. X    if (from_bang) {
  2528. X    BuildReceiveFile();
  2529. X    }
  2530. X
  2531. X    if (to_bang) {
  2532. X    BuildSendFile();
  2533. X    }
  2534. X
  2535. X    chdir(path);
  2536. X    exit(0);
  2537. X}
  2538. X
  2539. Xvoid
  2540. XBuildSendFile()
  2541. X{
  2542. X    FILE *fp;
  2543. X    char system_name[32];
  2544. X    int bang;
  2545. X
  2546. X    strcpy(from_buf,expand_file(from_buf));
  2547. X
  2548. X    bang = (int)strchr(to_buf,'!');
  2549. X    bang = bang - (int)to_buf;
  2550. X
  2551. X    strncpy(system_name,to_buf,bang);
  2552. X
  2553. X    system_name[bang] = '\0';
  2554. X
  2555. X    if (!is_in_L_sys_file(system_name)) {
  2556. X    printf("System \"%s\" not in L.sys file.\n", system_name);
  2557. X    chdir(path);
  2558. X    exit(1);
  2559. X    }
  2560. X
  2561. X    system_name[7] = '\0';
  2562. X
  2563. X    sprintf(command_file,"C.%sA%04d", system_name, seq++);
  2564. X
  2565. X    LockFile(command_file);
  2566. X
  2567. X    fp = fopen(command_file,"w");
  2568. X
  2569. X    if (fp) {
  2570. X    /* srcnam desnam who flags temp mode who */
  2571. X    fprintf(fp,"S %s %s %s %s %s %s %s\n",
  2572. X        from_buf,
  2573. X        to_buf + bang + 1,
  2574. X        user,
  2575. X        "-c",
  2576. X        from_buf,
  2577. X        "0666",
  2578. X        user
  2579. X    );
  2580. X    fclose(fp);
  2581. X    } else {
  2582. X    UnLockFile(command_file);
  2583. X    perror(command_file);
  2584. X    chdir(path);
  2585. X    exit(1);
  2586. X    }
  2587. X    UnLockFile(command_file);
  2588. X    printf("Command queue for transfer to %s.\n", system_name);
  2589. X}
  2590. X
  2591. Xvoid
  2592. XBuildReceiveFile()
  2593. X{
  2594. X    FILE *fp;
  2595. X    char system_name[32];
  2596. X    int bang;
  2597. X
  2598. X    strcpy(to_buf,expand_file(to_buf));
  2599. X
  2600. X    bang = (int)strchr(from_buf,'!');
  2601. X    bang = bang - (int)from_buf;
  2602. X
  2603. X    strncpy(system_name,from_buf,bang);
  2604. X
  2605. X    system_name[bang] = '\0';
  2606. X
  2607. X    if (!is_in_L_sys_file(system_name)) {
  2608. X    printf("System \"%s\" not in L.sys file.\n", system_name);
  2609. X    chdir(path);
  2610. X    exit(1);
  2611. X    }
  2612. X
  2613. X    system_name[7] = '\0';
  2614. X
  2615. X    sprintf(command_file,"C.%sA%04d", system_name, seq++);
  2616. X
  2617. X    LockFile(command_file);
  2618. X
  2619. X    fp = fopen(command_file,"w");
  2620. X    if (fp) {
  2621. X    /* srcnam desnam who flags */
  2622. X    fprintf(fp,"R %s %s %s %s\n",
  2623. X        from_buf + bang + 1,
  2624. X        to_buf,
  2625. X        user,
  2626. X        "-c"
  2627. X    );
  2628. X    fclose(fp);
  2629. X    } else {
  2630. X    UnLockFile(command_file);
  2631. X    perror(command_file);
  2632. X    chdir(path);
  2633. X    exit(1);
  2634. X    }
  2635. X    UnLockFile(command_file);
  2636. X    printf("Command queue for transfer from %s.\n", system_name);
  2637. X}
  2638. X
  2639. Xstatic char name[128];
  2640. X
  2641. Xchar *
  2642. Xexpand_file(file_name)
  2643. Xchar *file_name;
  2644. X{
  2645. X    char *colon;
  2646. X
  2647. X    colon = strchr(file_name,':');
  2648. X    if ((colon != (char*)NULL) && (colon != file_name)) {
  2649. X    return(file_name);
  2650. X    } else {
  2651. X    if (path[strlen(path)-1] != ':') {
  2652. X        sprintf(name,"%s/%s",path,file_name);
  2653. X        return name;
  2654. X    } else {
  2655. X        sprintf(name,"%s%s",path,file_name);
  2656. X        return name;
  2657. X    }
  2658. X    }
  2659. X}
  2660. X
  2661. X#define CTL_DELIM " \t\r\n"
  2662. X
  2663. X/*
  2664. X * Read the control file and grab a few parameters.
  2665. X */
  2666. X
  2667. Xvoid
  2668. Xread_ctl()
  2669. X{
  2670. X    FILE  *fd;
  2671. X    static char  buf[128];
  2672. X
  2673. X    if (! (fd = fopen(MakeConfigPath(UULIB, "Config"), "r"))) {
  2674. X    printf("Can't Find config file.\n");
  2675. X    chdir(path);
  2676. X    exit(3);
  2677. X    }
  2678. X
  2679. X    while (NULL != fgets(buf, sizeof buf, fd)) {
  2680. X    if (strncmp(buf, "UserName", 8) == 0)
  2681. X        strcpy(user, strtok(&buf[9], CTL_DELIM) ) ;
  2682. X    }
  2683. X    fclose(fd);
  2684. X}
  2685. X
  2686. X
  2687. END_OF_FILE
  2688. if test 4098 -ne `wc -c <'uucp2/src/uucico/uucp.c'`; then
  2689.     echo shar: \"'uucp2/src/uucico/uucp.c'\" unpacked with wrong size!
  2690. fi
  2691. # end of 'uucp2/src/uucico/uucp.c'
  2692. fi
  2693. if test -f 'uucp2/src/uucico/uux.c' -a "${1}" != "-c" ; then 
  2694.   echo shar: Will not clobber existing file \"'uucp2/src/uucico/uux.c'\"
  2695. else
  2696. echo shar: Extracting \"'uucp2/src/uucico/uux.c'\" \(3324 characters\)
  2697. sed "s/^X//" >'uucp2/src/uucico/uux.c' <<'END_OF_FILE'
  2698. X
  2699. X/*
  2700. X *  UUX.C
  2701. X *
  2702. X *  $Header: Beta:src/uucp/src/uucico/RCS/uux.c,v 1.1 90/02/02 11:56:20 dillon Exp Locker: dillon $
  2703. X *
  2704. X *  Copyright 1988 by William Loftus.    All rights reserved.
  2705. X *
  2706. X *  Example: 1> uux mail-message "burdvax!rmail wpl"
  2707. X */
  2708. X
  2709. X#include <stdio.h>
  2710. X#include <stdlib.h>
  2711. X#include <string.h>
  2712. X#include "version.h"
  2713. X
  2714. XIDENT(".02");
  2715. X
  2716. Xchar user[128];
  2717. Xchar file_name[128];
  2718. Xchar command[128];
  2719. X
  2720. Xchar exec_file[128];
  2721. Xchar x_exec_file[128];
  2722. Xchar command_file[128];
  2723. Xchar data_file[128];
  2724. Xint seq;
  2725. X
  2726. Xchar path[128];
  2727. X
  2728. Xvoid GetTo();
  2729. Xvoid GetSubject();
  2730. X
  2731. X#define TRUE 1
  2732. X#define FALSE 0
  2733. X
  2734. Xint
  2735. Xbrk()
  2736. X{
  2737. X    return(0);
  2738. X}
  2739. X
  2740. Xvoid
  2741. Xmain(argc, argv)
  2742. Xint argc;
  2743. Xchar **argv;
  2744. X{
  2745. X    int error;
  2746. X    char *up = FindConfig(USERNAME);
  2747. X
  2748. X    onbreak(brk);
  2749. X    if (up == NULL) {
  2750. X    printf("couldn't find domain entry for %s\n", USERNAME);
  2751. X    exit(1);
  2752. X    }
  2753. X    strcpy(user, up);
  2754. X
  2755. X    getcwd(path,128);
  2756. X    chdir(GetConfigDir(UUSPOOL));
  2757. X    if (argc == 3) {
  2758. X    strcpy(file_name, argv[1]);
  2759. X    strcpy(command, argv[2]);
  2760. X    } else {
  2761. X    printf("Usage: uux file-name command\n");
  2762. X    printf("Example: 1> uux mail-message \"burdvax!rmail wpl\"\n");
  2763. X    chdir(path);
  2764. X    exit(1);
  2765. X    }
  2766. X    seq = GetSequence(4);
  2767. X    if (seq >= 0)
  2768. X    error = Queue();
  2769. X    UnLockFile(exec_file);
  2770. X    UnLockFile(x_exec_file);
  2771. X    UnLockFile(command_file);
  2772. X    UnLockFile(data_file);
  2773. X    chdir(path);
  2774. X    if (seq < 0 || error < 0)
  2775. X    exit(1);
  2776. X}
  2777. X
  2778. XQueue()
  2779. X{
  2780. X    FILE *fp;
  2781. X    char system_name[32];
  2782. X    int bang;
  2783. X    int error;
  2784. X
  2785. X    bang = (int)strchr(command,'!');
  2786. X    bang = bang - (int)command;
  2787. X
  2788. X    strncpy(system_name,command,bang);
  2789. X
  2790. X    system_name[bang] = '\0';
  2791. X
  2792. X    if (!is_in_L_sys_file(system_name)) {
  2793. X    printf ("System \"%s\" not in L.sys file.\n", system_name);
  2794. X    return(-1);
  2795. X    }
  2796. X
  2797. X    system_name[7] = '\0';
  2798. X
  2799. X    sprintf(exec_file,"D.%sX%04d", system_name, seq++);
  2800. X    sprintf(x_exec_file,"X.%sX%04d", system_name, seq++);
  2801. X    sprintf(command_file,"C.%sA%04d", system_name, seq++);
  2802. X    sprintf(data_file,"D.%sB%04d", system_name, seq);
  2803. X
  2804. X    LockFile(exec_file);
  2805. X    LockFile(x_exec_file);
  2806. X    LockFile(command_file);
  2807. X    LockFile(data_file);
  2808. X
  2809. X    fp = fopen(exec_file,"w");
  2810. X    if (fp) {
  2811. X    fprintf(fp,"U %s\n", user);
  2812. X    fprintf(fp,"F %s\n", data_file);
  2813. X    fprintf(fp,"I %s\n", data_file);
  2814. X    fprintf(fp,"C %s\n", (char *)command + bang + 1);
  2815. X    fclose(fp);
  2816. X    } else {
  2817. X    perror(exec_file);
  2818. X    return(-1);
  2819. X    }
  2820. X
  2821. X    fp = fopen(command_file,"w");
  2822. X    if (fp) {
  2823. X    fprintf(fp,"S %s %s %s - %s 0666\n",
  2824. X        data_file,
  2825. X        data_file,
  2826. X        user,
  2827. X        data_file
  2828. X    );
  2829. X    fprintf(fp,"S %s %s %s - %s 0666\n",
  2830. X        exec_file,
  2831. X        x_exec_file,
  2832. X        user,
  2833. X        exec_file
  2834. X    );
  2835. X    fclose(fp);
  2836. X    } else {
  2837. X    perror(command_file);
  2838. X    return(-1);
  2839. X    }
  2840. X    chdir(path);
  2841. X    error =  Copy(file_name, data_file);
  2842. X    chdir(GetConfigDir(UUSPOOL));
  2843. X    return(error);
  2844. X}
  2845. X
  2846. X/*
  2847. X * Read the control file and grab a few parameters.
  2848. X */
  2849. X
  2850. XCopy(from, to)
  2851. Xchar *from;
  2852. Xchar *to;
  2853. X{
  2854. X    FILE *fd;
  2855. X    FILE *td;
  2856. X    int c;
  2857. X    static char to_buf[128];
  2858. X
  2859. X    fd = fopen(from, "r");
  2860. X    if (!fd) {
  2861. X    printf("Could not open %s.\n", from);
  2862. X    perror(from);
  2863. X    return(-1);
  2864. X    }
  2865. X
  2866. X    strcpy(to_buf, MakeConfigPath(UUSPOOL, to));
  2867. X
  2868. X    td = fopen(to_buf, "w");
  2869. X    if (!td) {
  2870. X    printf("Could not open %s.\n", to_buf);
  2871. X    perror(to);
  2872. X    return(-1);
  2873. X    }
  2874. X    while ((c = fgetc(fd)) != EOF) {
  2875. X    fputc((char)c, td);
  2876. X    }
  2877. X    fclose(fd);
  2878. X    fclose(td);
  2879. X    return(1);
  2880. X}
  2881. X
  2882. X
  2883. END_OF_FILE
  2884. if test 3324 -ne `wc -c <'uucp2/src/uucico/uux.c'`; then
  2885.     echo shar: \"'uucp2/src/uucico/uux.c'\" unpacked with wrong size!
  2886. fi
  2887. # end of 'uucp2/src/uucico/uux.c'
  2888. fi
  2889. echo shar: End of archive 4 \(of 12\).
  2890. cp /dev/null ark4isdone
  2891. MISSING=""
  2892. for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
  2893.     if test ! -f ark${I}isdone ; then
  2894.     MISSING="${MISSING} ${I}"
  2895.     fi
  2896. done
  2897. if test "${MISSING}" = "" ; then
  2898.     echo You have unpacked all 12 archives.
  2899.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2900. else
  2901.     echo You still need to unpack the following archives:
  2902.     echo "        " ${MISSING}
  2903. fi
  2904. ##  End of shell archive.
  2905. exit 0
  2906. -- 
  2907. Mail submissions (sources or binaries) to <amiga@cs.odu.edu>.
  2908. Mail comments to the moderator at <amiga-request@cs.odu.edu>.
  2909. Post requests for sources, and general discussion to comp.sys.amiga.
  2910.